1.pip镜像源
豆瓣镜像源(推荐)
以安装wxpython为例
pip install wxpython -i http://pypi.douban.com/simple
若出错,此命令变换为
pip install wxpython -i http://douban.com/simple --trusted-host pypi.douban.com
或者
pip install -i http://doubanio.com/simple/ --trusted-host pypi.doubanio.com wxpython
其它镜像源
清华大学https://pypi.tuna.tsinghua.edu.cn/simple/
阿里云http://mirrors.aliyun.com/pypi/simple/
中国科技大学https://pypi.mirrors.ustc.edu.cn/simple/
中国科学技术大学http://pypi.mirrors.ustc.edu.cn/simple/
永久置换pip镜像源
1.创建pip.conf文件
运行以下命令
cd ~/.pip
如果提示目录不存在的话,我们要自行创建一个,再进入目录
mkdir ~/.pip
cd ~/.pip
在.pip目录下创建一个pip.conf文件
touch pip.conf
2.编辑pip.conf文件
sudo gedit ~/.pip/pip.conf
打开pip.conf文件窗口,将以下内容复制到文件中
[global]
index-url = http://douban.com/simple
[install]
trusted-host=pypi.douban.com
这样就替换成功,也可以选择其他镜像源
2.conda 镜像源
2.1 Linux换源
打开终端,输入命令
gedit ~/.condarc
然后填入下面的内容
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
替换成功
3.部分库安装
3.1 linux下
pytorch 官网给的代码如下:
conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch
其中,-c pytorch参数指定了conda获取pytorch的channel,在此指定为conda自带的pytorch仓库。
因此,只需要将-c pytorch语句去掉,就可以使用清华镜像源快速安装pytorch了
conda install pytorch torchvision cudatoolkit=9.0