问题:通过默认镜像安装,下载过程中可能会报错,下载安装失败
Traceback (most recent call last):
File “E:\Anaconda3\lib\site-packages\pip_vendor\urllib3\response.py”, line , in _error_catcher
yield
File “E:\Anaconda3\lib\site-packages\pip_vendor\urllib3\response.py”, line , in read
data = self._fp.read(amt)
File “E:\Anaconda3\lib\site-packages\pip_vendor\cachecontrol\filewrapper.py”, line , in read
data = self.__fp.read(amt)
File “E:\Anaconda3\lib\http\client.py”, line , in read
n = self.readinto(b)
File “E:\Anaconda3\lib\http\client.py”, line , in readinto
n = self.fp.readinto(b)
File “E:\Anaconda3\lib\socket.py”, line , in readinto
return self._sock.recv_into(b)
File “E:\Anaconda3\lib\ssl.py”, line , in recv_into
return self.read(nbytes, buffer)
File “E:\Anaconda3\lib\ssl.py”, line , in read
return self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last):
File “E:\Anaconda3\lib\site-packages\pip_internal\cli\base_command.py”, line , in main
status = self.run(options, args)
File “E:\Anaconda3\lib\site-packages\pip_internal\commands\install.py”, line , in run
resolver.resolve(requirement_set)
File “E:\Anaconda3\lib\site-packages\pip_internal\resolve.py”, line , in resolve
self._resolve_one(requirement_set, req)
File “E:\Anaconda3\lib\site-packages\pip_internal\resolve.py”, line , in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File “E:\Anaconda3\lib\site-packages\pip_internal\resolve.py”, line , in _get_abstract_dist_for
self.require_hashes
File “E:\Anaconda3\lib\site-packages\pip_internal\operations\prepare.py”, line , in prepare_linked_requirement
progress_bar=self.progress_bar
File “E:\Anaconda3\lib\site-packages\pip_internal\download.py”, line , in unpack_url
progress_bar=progress_bar
File “E:\Anaconda3\lib\site-packages\pip_internal\download.py”, line , in unpack_http_url
progress_bar)
File “E:\Anaconda3\lib\site-packages\pip_internal\download.py”, line , in _download_http_url
_download_url(resp, link, content_file, hashes, progress_bar)
File “E:\Anaconda3\lib\site-packages\pip_internal\download.py”, line , in _download_url
hashes.check_against_chunks(downloaded_chunks)
File “E:\Anaconda3\lib\site-packages\pip_internal\utils\hashes.py”, line , in check_against_chunks
for chunk in chunks:
File “E:\Anaconda3\lib\site-packages\pip_internal\download.py”, line , in written_chunks
for chunk in chunks:
File “E:\Anaconda3\lib\site-packages\pip_internal\utils\ui.py”, line , in iter
for x in it:
File “E:\Anaconda3\lib\site-packages\pip_internal\download.py”, line , in resp_read
decode_content=False):
File “E:\Anaconda3\lib\site-packages\pip_vendor\urllib3\response.py”, line , in stream
data = self.read(amt=amt, decode_content=decode_content)
File “E:\Anaconda3\lib\site-packages\pip_vendor\urllib3\response.py”, line , in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File “E:\Anaconda3\lib\contextlib.py”, line , in exit
self.gen.throw(type, value, traceback)
File “E:\Anaconda3\lib\site-packages\pip_vendor\urllib3\response.py”, line , in _error_catcher
raise ReadTimeoutError(self._pool, None, ‘Read timed out.’)
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=): Read timed out.
解决方法:一般可以考虑更换镜像源
pip install tensorflow -i https://pypi.douban.com/simple
结果:安装成功,并且速度快
(base) C:\Users\Administrator>pip install tensorflow -i https://pypi.douban.com/simple
Looking in indexes: https://pypi.douban.com/simple
Collecting tensorflow
Downloading https://pypi.doubanio.com/packages/7b/14/e4538c2bc3ae9f4ce6f6ce7ef1180da05abc4a617afba798268232b01d0d/tensorflow-1.13.1-cp37-cp37m-win_amd64.whl (63.1MB)
% |████████████████████████████████| .1MB 207kB/s
Collecting keras-preprocessing>=1.0. (from tensorflow)
Downloading https://pypi.doubanio.com/packages/c0/bf/0315ef6a9fd3fc2346e85b0ff1f5f83ca17073f2c31ac719ab2e4da0d4a3/Keras_Preprocessing-1.0.9-py2.py3-none-any.whl (59kB)
% |████████████████████████████████| 61kB .1MB/s
Requirement already satisfied: numpy>=1.13. in e:\anaconda3\lib\site-packages (from tensorflow) (1.16.)
Collecting tensorboard<1.14.,>=1.13. (from tensorflow)
Downloading https://pypi.doubanio.com/packages/0f/39/bdd75b08a6fba41f098b6cb091b9e8c7a80e1b4d679a581a0ccd17b10373/tensorboard-1.13.1-py3-none-any.whl (3.2MB)
% |████████████████████████████████| .2MB .5MB/s
Requirement already satisfied: six>=1.10. in e:\anaconda3\lib\site-packages (from tensorflow) (1.12.)
Requirement already satisfied: wheel>=0.26 in e:\anaconda3\lib\site-packages (from tensorflow) (0.33.)
Collecting gast>=0.2. (from tensorflow)
Downloading https://pypi.doubanio.com/packages/4e/35/11749bf99b2d4e3cceb4d55ca22590b0d7c2c62b9de38ac4a4a7f4687421/gast-0.2.2.tar.gz
Collecting tensorflow-estimator<1.14.0rc0,>=1.13. (from tensorflow)
Downloading https://pypi.doubanio.com/packages/bb/48/13f49fc3fa0fdf916aa1419013bb8f2ad09674c275b4046d5ee669a46873/tensorflow_estimator-1.13.0-py2.py3-none-any.whl (367kB)
% |████████████████████████████████| 368kB .3MB/s
Collecting termcolor>=1.1. (from tensorflow)
Downloading https://pypi.doubanio.com/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
Collecting keras-applications>=1.0. (from tensorflow)
Downloading https://pypi.doubanio.com/packages/90/85/64c82949765cfb246bbdaf5aca2d55f400f792655927a017710a78445def/Keras_Applications-1.0.7-py2.py3-none-any.whl (51kB)
% |████████████████████████████████| 61kB .1MB/s
Collecting absl-py>=0.1. (from tensorflow)
Downloading https://pypi.doubanio.com/packages/da/3f/9b0355080b81b15ba6a9ffcf1f5ea39e307a2778b2f2dc8694724e8abd5b/absl-py-0.7.1.tar.gz (99kB)
% |████████████████████████████████| 102kB .8MB/s
Collecting grpcio>=1.8. (from tensorflow)
Downloading https://pypi.doubanio.com/packages/2a/22/bd327063dd0bdf9d8d640b3185b760707842160e69df909db3fcaab5b758/grpcio-1.20.1-cp37-cp37m-win_amd64.whl (1.6MB)
% |████████████████████████████████| .6MB .4MB/s
Collecting astor>=0.6. (from tensorflow)
Downloading https://pypi.doubanio.com/packages/d1/4f/950dfae467b384fc96bc6469de25d832534f6b4441033c39f914efd13418/astor-0.8.0-py2.py3-none-any.whl
Collecting protobuf>=3.6. (from tensorflow)
Downloading https://pypi.doubanio.com/packages/34/ef/f020691889031a8e1d8cb20711daa43cfe999e0768ff6903c4bf70c2eecd/protobuf-3.7.1-cp37-cp37m-win_amd64.whl (986kB)
% |████████████████████████████████| 993kB .9MB/s
Requirement already satisfied: werkzeug>=0.11. in e:\anaconda3\lib\site-packages (from tensorboard<1.14.,>=1.13.->tensorflow) (0.14.)
Collecting markdown>=2.6. (from tensorboard<1.14.,>=1.13.->tensorflow)
Downloading https://pypi.doubanio.com/packages/c0/4e/fd492e91abdc2d2fcb70ef453064d980688762079397f779758e055f6575/Markdown-3.1.1-py2.py3-none-any.whl (87kB)
% |████████████████████████████████| 92kB .1MB/s
Collecting mock>=2.0. (from tensorflow-estimator<1.14.0rc0,>=1.13.->tensorflow)
Downloading https://pypi.doubanio.com/packages/05/d2/f94e68be6b17f46d2c353564da56e6fb89ef09faeeff3313a046cb810ca9/mock-3.0.5-py2.py3-none-any.whl
Requirement already satisfied: h5py in e:\anaconda3\lib\site-packages (from keras-applications>=1.0.->tensorflow) (2.9.)
Requirement already satisfied: setuptools in e:\anaconda3\lib\site-packages (from protobuf>=3.6.->tensorflow) (40.8.)
Building wheels for collected packages: gast, termcolor, absl-py
Building wheel for gast (setup.py) … done
Stored in directory: C:\Users\Administrator\AppData\Local\pip\Cache\wheels\6c\eb\\547988c386be0acb0797611e9b1a96564e7200bf60be924c80
Building wheel for termcolor (setup.py) … done
Stored in directory: C:\Users\Administrator\AppData\Local\pip\Cache\wheels\\b4\7c\713366bcd4e4f6d38377a66e0742bd15e6920b1939be008dbb
Building wheel for absl-py (setup.py) … done
Stored in directory: C:\Users\Administrator\AppData\Local\pip\Cache\wheels\\\e5\139c27ec57828631565111db6facbddd0eb13bf73e1764e8c0
Successfully built gast termcolor absl-py
Installing collected packages: keras-preprocessing, protobuf, markdown, grpcio, absl-py, tensorboard, gast, mock, tensorflow-estimator, termcolor, keras-applications, astor, tensorflow
Successfully installed absl-py-0.7. astor-0.8. gast-0.2. grpcio-1.20. keras-applications-1.0. keras-preprocessing-1.0. markdown-3.1. mock-3.0. protobuf-3.7. tensorboard-1.13. tensorflow-1.13. tensorflow-estimator-1.13. termcolor-1.1.