今天学习SSD需要用到keras库,在安装时遇到了一些问题如下:
(tensorflow) C:\Users\Acer>pip install keras==1.2.2
Collecting keras==1.2.2
Downloading Keras-1.2.2.tar.gz (175 kB)
---------------------------- ----------- 122.9/175.5 KB 84.8 kB/s eta 0:00:01
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
yield
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_vendor\urllib3\response.py", line 519, in read
data = self._fp.read(amt) if not fp_closed else b""
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 90, in read
data = self.__fp.read(amt)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\http\client.py", line 465, in read
n = self.readinto(b)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\http\client.py", line 509, in readinto
n = self.fp.readinto(b)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\socket.py", line 589, in readinto
return self._sock.recv_into(b)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\ssl.py", line 1071, in recv_into
return self.read(nbytes, buffer)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\ssl.py", line 929, 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 "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
status = run_func(*args)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\cli\req_command.py", line 205, in wrapper
return func(self, options, args)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\commands\install.py", line 340, in run
reqs, check_supported_wheels=not options.target_dir
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 95, in resolve
collected.requirements, max_rounds=try_to_avoid_resolution_too_deep
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 481, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 348, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
if not criterion.candidates:
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 151, in __bool__
return bool(self._sequence)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 155, in __bool__
return any(self)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 143, in
return (c for c in iterator if id(c) not in self._incompatible_ids)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 47, in _iter_built
candidate = func()
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 220, in _make_candidate_from_link
version=version,
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 294, in __init__
version=version,
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 158, in __init__
self.dist = self._prepare()
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 227, in _prepare
dist = self._prepare_distribution()
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 299, in _prepare_distribution
return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\operations\prepare.py", line 487, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\operations\prepare.py", line 538, in _prepare_linked_requirement
hashes,
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\operations\prepare.py", line 218, in unpack_url
hashes=hashes,
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\operations\prepare.py", line 94, in get_http_url
from_path, content_type = download(link, temp_dir.path)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\network\download.py", line 146, in __call__
for chunk in chunks:
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\cli\progress_bars.py", line 304, in _rich_progress_bar
for chunk in iterable:
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_internal\network\utils.py", line 87, in response_chunks
decode_content=False,
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_vendor\urllib3\response.py", line 541, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\contextlib.py", line 130, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Users\Acer\.conda\envs\tensorflow\lib\site-packages\pip\_vendor\urllib3\response.py", line 443, 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.
前面一大堆不知道是错在哪,看到最后关键的一句
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
Read timed out.超时了
在网上找了一下资料,终于找到了解决办法。
在项目所在的环境中修改,设置超时时间:
pip --default-timeout=100 install -U Pillow
(tensorflow) C:\Users\Acer>pip --default-timeout=100 install -U Pillow
Requirement already satisfied: Pillow in c:\users\acer\.conda\envs\tensorflow\lib\site-packages (9.1.0)
Collecting Pillow
Downloading Pillow-9.1.1-cp37-cp37m-win_amd64.whl (3.3 MB)
---------------------------------------- 3.3/3.3 MB 113.0 kB/s eta 0:00:00
Installing collected packages: Pillow
Attempting uninstall: Pillow
Found existing installation: Pillow 9.1.0
Uninstalling Pillow-9.1.0:
Successfully uninstalled Pillow-9.1.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
matplotlib 3.5.2 requires numpy>=1.17, but you have numpy 1.16.5 which is incompatible.
Successfully installed Pillow-9.1.1
设置好之后,再次安装keras库,就可以了
(tensorflow) C:\Users\Acer>pip install keras==1.2.2
Collecting keras==1.2.2
Downloading Keras-1.2.2.tar.gz (175 kB)
---------------------------------------- 175.5/175.5 KB 278.6 kB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting theano
Downloading Theano-1.0.5.tar.gz (2.8 MB)
---------------------------------------- 2.8/2.8 MB 46.3 kB/s eta 0:00:00
Preparing metadata (setup.py) ... done
Collecting pyyaml
Using cached PyYAML-6.0-cp37-cp37m-win_amd64.whl (153 kB)
Requirement already satisfied: six in c:\users\acer\.conda\envs\tensorflow\lib\site-packages (from keras==1.2.2) (1.16.0)
Requirement already satisfied: numpy>=1.9.1 in c:\users\acer\.conda\envs\tensorflow\lib\site-packages (from theano->keras==1.2.2) (1.16.5)
Requirement already satisfied: scipy>=0.14 in c:\users\acer\.conda\envs\tensorflow\lib\site-packages (from theano->keras==1.2.2) (1.7.3)
Building wheels for collected packages: keras, theano
Building wheel for keras (setup.py) ... done
Created wheel for keras: filename=Keras-1.2.2-py3-none-any.whl size=209603 sha256=a09df34f79d7be79f490aed3f9c34a7568c7acf39060fca37410fd66d8ef31b0
Stored in directory: c:\users\acer\appdata\local\pip\cache\wheels\d1\32\23\2a1db3765ec19c91503843380a4f92b6530598949c661c5fa2
Building wheel for theano (setup.py) ... done
Created wheel for theano: filename=Theano-1.0.5-py3-none-any.whl size=2668124 sha256=baff978414aacc3ccdcf391b393f22037d6cffa7f59b892c21b2fadcb0a632ce
Stored in directory: c:\users\acer\appdata\local\pip\cache\wheels\26\68\6f\745330367ce7822fe0cd863712858151f5723a0a5e322cc144
Successfully built keras theano
Installing collected packages: pyyaml, theano, keras
Successfully installed keras-1.2.2 pyyaml-6.0 theano-1.0.5
最后显示,成功安装,撒花。。。。
这个也可以应用于python安装其他的第三方库超时的情况。如果这样操作之后还行显示超时,那么可能是网络问题,换一个比较好的网络环境再多试几次。
参考资料:python 安装第三方库,超时报错--Read timed out.(亲测有效)_小志的博客的博客-CSDN博客