yongqiang@famu-sys:~$ sudo pip install tensorflow-gpu==1.4.0
[sudo] yongqiang 的密码:
WARNING: The directory '/home/yongqiang/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/yongqiang/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting tensorflow-gpu==1.4.0
Downloading https://files.pythonhosted.org/packages/3d/59/7b74db1ce032b5368d96d0b0965baa02b8d6a91726b4ed58be249c268e98/tensorflow_gpu-1.4.0-cp35-cp35m-manylinux1_x86_64.whl (170.1MB)
|████ | 21.5MB 4.0kB/s eta 10:25:18ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/urllib3/response.py", line 360, in _error_catcher
yield
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/urllib3/response.py", line 442, in read
data = self._fp.read(amt)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "/usr/lib/python3.5/http/client.py", line 448, in read
n = self.readinto(b)
File "/usr/lib/python3.5/http/client.py", line 488, in readinto
n = self.fp.readinto(b)
File "/usr/lib/python3.5/socket.py", line 575, in readinto
return self._sock.recv_into(b)
File "/usr/lib/python3.5/ssl.py", line 929, in recv_into
return self.read(nbytes, buffer)
File "/usr/lib/python3.5/ssl.py", line 791, in read
return self._sslobj.read(len, buffer)
File "/usr/lib/python3.5/ssl.py", line 575, in read
v = 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 "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/base_command.py", line 178, in main
status = self.run(options, args)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/commands/install.py", line 352, in run
resolver.resolve(requirement_set)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/resolve.py", line 131, in resolve
self._resolve_one(requirement_set, req)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/resolve.py", line 294, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/resolve.py", line 242, in _get_abstract_dist_for
self.require_hashes
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/operations/prepare.py", line 347, in prepare_linked_requirement
progress_bar=self.progress_bar
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 886, in unpack_url
progress_bar=progress_bar
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 746, in unpack_http_url
progress_bar)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 954, in _download_http_url
_download_url(resp, link, content_file, hashes, progress_bar)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 683, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/utils/hashes.py", line 62, in check_against_chunks
for chunk in chunks:
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 651, in written_chunks
for chunk in chunks:
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/utils/ui.py", line 156, in iter
for x in it:
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/download.py", line 640, in resp_read
decode_content=False):
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/urllib3/response.py", line 494, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/urllib3/response.py", line 459, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/lib/python3.5/contextlib.py", line 77, in __exit__
self.gen.throw(type, value, traceback)
File "/usr/local/lib/python3.5/dist-packages/pip/_vendor/urllib3/response.py", line 365, in _error_catcher
raise ReadTimeoutError(self._pool, None, 'Read timed out.')
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
yongqiang@famu-sys:~$
网络原因导致的安装超时,重新下载。
下载命令后添加参数 --default-timeout=1000
,时间可以自定义。
pip install 默认超时时间是 15s,在安装的过程中可能会超时。我们在执行命令时,可显式指定超时时间。
--default-timeout=100
--default-timeout=1000
sudo pip3 --default-timeout=100 install opencv-python==3.4.0.14
sudo pip3 --default-timeout=1000 install opencv-python==3.4.0.14
https://pypi.tuna.tsinghua.edu.cn/simple
sudo pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple scipy
sudo pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple scikit-learn
https://pypi.douban.com/simple
sudo pip3 install -i https://pypi.douban.com/simple scipy
sudo pip3 install -i https://pypi.douban.com/simple scikit-learn