最近重装了Ubuntu系统,更新到了Ubuntu 18.04,于是numpy也需要重新安装,但是一开始会出错,报错如下:
Could not find a version that satisfies the requirement numpy (from versions: )
No matching distribution found for numpy
或许是因为国内连接外国的源的时候网络会出现错误,所以有必要使用国内的镜像源,推荐豆瓣的源,更换方法也很简单,只要在后面加上:
-i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
例如我在安装numpy的时候是:
pip3 install numpy
然后就会有上述错误,可以改成
pip3 install numpy -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
再例如在安装tensorflow的时候也会出现该错误:
A@A:~$ pip3 install tensorflow
Collecting tensorflow
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/tensorflow/
Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/tensorflow/
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/tensorflow/
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/tensorflow/
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))': /simple/tensorflow/
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
可以改成:
pip3 install tensorflow -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
A@A:~$ pip3 install tensorflow -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
Collecting tensorflow
Downloading http://pypi.doubanio.com/packages/ce/d5/38cd4543401708e64c9ee6afa664b936860f4630dd93a49ab863f9998cd2/tensorflow-1.11.0-cp36-cp36m-manylinux1_x86_64.whl (63.0MB)
100% |████████████████████████████████| 63.0MB 831kB/s
Collecting numpy>=1.13.3 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/16/21/2e88568c134cc3c8d22af290865e2abbd86efa58a1358ffcb19b6c74f9a3/numpy-1.15.3-cp36-cp36m-manylinux1_x86_64.whl (13.9MB)
100% |████████████████████████████████| 13.9MB 975kB/s
Collecting setuptools<=39.1.0 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/8c/10/79282747f9169f21c053c562a0baa21815a8c7879be97abd930dbcf862e8/setuptools-39.1.0-py2.py3-none-any.whl (566kB)
100% |████████████████████████████████| 573kB 1.0MB/s
Collecting grpcio>=1.8.6 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/c3/4c/0a7c55764ac3013ca7a5e9638ee7b161488c0611afc2be465452987a3ccc/grpcio-1.16.0-cp36-cp36m-manylinux1_x86_64.whl (9.7MB)
100% |████████████████████████████████| 9.7MB 1.0MB/s
Collecting six>=1.10.0 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting absl-py>=0.1.6 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/0c/63/f505d2d4c21db849cf80bad517f0065a30be6b006b0a5637f1b95584a305/absl-py-0.6.1.tar.gz (94kB)
100% |████████████████████████████████| 102kB 1.2MB/s
Collecting keras-preprocessing>=1.0.3 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/fc/94/74e0fa783d3fc07e41715973435dd051ca89c550881b3454233c39c73e69/Keras_Preprocessing-1.0.5-py2.py3-none-any.whl
Collecting tensorboard<1.12.0,>=1.11.0 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/9b/2f/4d788919b1feef04624d63ed6ea45a49d1d1c834199ec50716edb5d310f4/tensorboard-1.11.0-py3-none-any.whl (3.0MB)
100% |████████████████████████████████| 3.0MB 23.1MB/s
Collecting protobuf>=3.6.0 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/c2/f9/28787754923612ca9bfdffc588daa05580ed70698add063a5629d1a4209d/protobuf-3.6.1-cp36-cp36m-manylinux1_x86_64.whl (1.1MB)
100% |████████████████████████████████| 1.1MB 1.0MB/s
Collecting keras-applications>=1.0.5 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/3f/c4/2ff40221029f7098d58f8d7fb99b97e8100f3293f9856f0fb5834bef100b/Keras_Applications-1.0.6-py2.py3-none-any.whl (44kB)
100% |████████████████████████████████| 51kB 1.6MB/s
Collecting wheel>=0.26 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/5a/9b/6aebe9e2636d35d1a93772fa644c828303e1d5d124e8a88f156f42ac4b87/wheel-0.32.2-py2.py3-none-any.whl
Collecting astor>=0.6.0 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/35/6b/11530768cac581a12952a2aad00e1526b89d242d0b9f59534ef6e6a1752f/astor-0.7.1-py2.py3-none-any.whl
Collecting termcolor>=1.1.0 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
Collecting gast>=0.2.0 (from tensorflow)
Downloading http://pypi.doubanio.com/packages/5c/78/ff794fcae2ce8aa6323e789d1f8b3b7765f601e7702726f430e814822b96/gast-0.2.0.tar.gz
Collecting markdown>=2.6.8 (from tensorboard<1.12.0,>=1.11.0->tensorflow)
Downloading http://pypi.doubanio.com/packages/7a/6b/5600647404ba15545ec37d2f7f58844d690baf2f81f3a60b862e48f29287/Markdown-3.0.1-py2.py3-none-any.whl (89kB)
100% |████████████████████████████████| 92kB 1.2MB/s
Collecting werkzeug>=0.11.10 (from tensorboard<1.12.0,>=1.11.0->tensorflow)
Downloading http://pypi.doubanio.com/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
100% |████████████████████████████████| 327kB 1.4MB/s
Collecting h5py (from keras-applications>=1.0.5->tensorflow)
Downloading http://pypi.doubanio.com/packages/8e/cb/726134109e7bd71d98d1fcc717ffe051767aac42ede0e7326fd1787e5d64/h5py-2.8.0-cp36-cp36m-manylinux1_x86_64.whl (2.8MB)
100% |████████████████████████████████| 2.8MB 1.1MB/s
Building wheels for collected packages: absl-py, termcolor, gast
Running setup.py bdist_wheel for absl-py ... done
Stored in directory: /home/huajie/.cache/pip/wheels/ff/87/00/cb10883b8fcb6fbc46a0011e3a00e89cc6938d50d4880e3a9e
Running setup.py bdist_wheel for termcolor ... done
Stored in directory: /home/huajie/.cache/pip/wheels/12/ef/81/0a093cc726842acb8f2a8c2455b28d4c333db4b7bef81fdf90
Running setup.py bdist_wheel for gast ... done
Stored in directory: /home/huajie/.cache/pip/wheels/af/f5/6b/969ee0fce5a60134761e2949c105918c9ff8938256be496541
Successfully built absl-py termcolor gast
Installing collected packages: numpy, setuptools, six, grpcio, absl-py, keras-preprocessing, markdown, werkzeug, protobuf, wheel, tensorboard, h5py, keras-applications, astor, termcolor, gast, tensorflow
Successfully installed absl-py-0.6.1 astor-0.7.1 gast-0.2.0 grpcio-1.16.0 h5py-2.8.0 keras-applications-1.0.6 keras-preprocessing-1.0.5 markdown-3.0.1 numpy-1.15.3 protobuf-3.6.1 setuptools-39.1.0 six-1.11.0 tensorboard-1.11.0 tensorflow-1.11.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.32.2