https://pypi.org/project/torch/#history
一、关于conda
CondaHTTPError: HTTP 000 CONNECTION FAILED for url <https://conda.anaconda.org/pytorch/linux-64/pytorch-nightly-1.0.0.dev20190207-py3.7_cuda8.0.61_cudnn7.1.2_0.tar.bz2>
1.添加 下清华镜像的Anaconda Python 免费仓库。
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
或者直接打开gedit ~/.condarc编辑 后为
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
show_channel_urls: true
ps:这是首先从最新添加的链接(最上面)找,找到就不找其他的了
https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free 有些老了,很多东西的版本不是很好,不建议使用
2.# 运行 conda install × 进行相应库的安装。
二、关于pip
ps:依然下不了,到https://pypi.org/project/找一下.whl文件。
pip install 一下
ReadTimeoutError: HTTPSConnectionPool(host='download.pytorch.org', port=443): Read timed out.
1、按照提示升级pip。如果没有忽略
2. 控制超时(依然慢)
pip --default-timeout=1000 install -U Pillow
3、临时使用,使用国内镜像下载python库:
pip install --index https://pypi.mirrors.ustc.edu.cn/simple matplotlib
easy_install
sudo easy_install -i http://pypi.douban.com/simple matplotlib
pip
sudo pip install matplotlib -i http://pypi.douban.com/simple
如果下载其他包更换matplotlib为目标包即可。--index后面也可以换成别的镜像。
但有时候可能会出现错误:如安装torch时候
Collecting torch
The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored.
If this repository is available via HTTPS we recommend you use HTTPS instead,
otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'.
Could not find a version that satisfies the requirement torch (from versions: )
No matching distribution found for torch
#阿里云
eg:安装:
pip install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com torch
eg:更新:
pip install --upgrade -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com torch
#清华
eg:更新
pip install --upgrade -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host https://pypi.tuna.tsinghua.edu.cn/ torch
eg:安装:
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host https://pypi.tuna.tsinghua.edu.cn/ torch
4、一次修改(我老是不成功 不知道为什么)
Linux下,sudo gedit ~/.pip/pip.conf (没有就创建一个), 修改 index-url至tuna,内容如下:
[global]
timeout=600
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
windows下,
(1):在windows文件管理器中,输入 %APPDATA%
(2):会定位到一个新的目录下,eg:"C:\Users\Administrator\AppData\Roaming"
(3):在该目录下新建pip文件夹,到pip文件夹里新建pip.ini文件("C:\Users\Administrator\AppData\Roaming\pip\pip.ini"),内容如下:
eg:豆瓣
[global]
timeout = 6000
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
eg:阿里云
[global]
timeout = 6000
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
timeout :以免网络慢的情况下安装包下载不完
index-url:要安装的python包存放的链接地址
easy_install:在sudo gedit ~/.pydistutils.cfg配置文件中写入如下内容
[easy_install]
index_url = http://pypi.douban.com/simple
几个国内的PyPI镜像源,最上方的源在我这访问速度最快,速度依次向下递减,所以试一试前几个就好了。
阿里云 速度最快 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
Python官方 https://pypi.python.org/simple/
v2ex http://pypi.v2ex.com/simple/
中国科学院 http://pypi.mirrors.opencas.cn/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
使用镜像源,用-i指定就行了,例如:
sudo easy_install -i http://pypi.douban.com/simple/ saltTesting
sudo pip install -i http://pypi.douban.com/simple/ saltTesting
本文介绍了当conda和pip安装遇到问题时,如何利用阿里清华镜像源进行快速安装。对于conda,推荐添加清华镜像以解决CondaHTTPError,对于pip,给出了在下载慢或ReadTimeoutError时的处理办法,包括升级pip、控制超时和使用国内镜像源。还提供了具体的操作指令和镜像源链接。

1116

被折叠的 条评论
为什么被折叠?



