解决anaconda下载时的Traceback报错问题

在Anaconda Prompt使用pip insatall 库名 ,出现超时报错,报错代码如下

(datasci) C:\Users\德玛西亚>pip install pandas==1.1.3
Collecting pandas==1.1.3
  Downloading pandas-1.1.3-cp38-cp38-win_amd64.whl (8.9 MB)
     -------- ------------------------------- 1.9/8.9 MB 18.7 kB/s eta 0:06:20
ERROR: Exception:
Traceback (most recent call last):
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_vendor\urllib3\response.py", line 435, in _error_catcher
    yield
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_vendor\urllib3\response.py", line 516, in read
    data = self._fp.read(amt) if not fp_closed else b""
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 90, in read
    data = self.__fp.read(amt)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\http\client.py", line 459, in read
    n = self.readinto(b)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\http\client.py", line 503, in readinto
    n = self.fp.readinto(b)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\ssl.py", line 1099, 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 "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\cli\base_command.py", line 167, in exc_logging_wrapper
    status = run_func(*args)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\cli\req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\commands\install.py", line 341, in run
    requirement_set = resolver.resolve(
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 94, in resolve
    result = self._result = resolver.resolve(
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 481, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 348, in resolve
    self._add_to_criteria(self.state.criteria, r, parent=None)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
    if not criterion.candidates:
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 151, in __bool__
    return bool(self._sequence)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 155, in __bool__
    return any(self)
  File "D:\learnBigdata\Anaconda3\envs\datasci\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 "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 47, in _iter_built
    candidate = func()
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 215, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 291, in __init__
    super().__init__(
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 161, in __init__
    self.dist = self._prepare()
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 230, in _prepare
    dist = self._prepare_distribution()
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 302, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\operations\prepare.py", line 428, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\operations\prepare.py", line 473, in _prepare_linked_requirement
    local_file = unpack_url(
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\operations\prepare.py", line 155, in unpack_url
    file = get_http_url(
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\operations\prepare.py", line 96, in get_http_url
    from_path, content_type = download(link, temp_dir.path)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\network\download.py", line 146, in __call__
    for chunk in chunks:
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\cli\progress_bars.py", line 53, in _rich_progress_bar
    for chunk in iterable:
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_internal\network\utils.py", line 63, in response_chunks
    for chunk in response.raw.stream(
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_vendor\urllib3\response.py", line 573, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_vendor\urllib3\response.py", line 538, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\contextlib.py", line 131, in __exit__
    self.gen.throw(type, value, traceback)
  File "D:\learnBigdata\Anaconda3\envs\datasci\lib\site-packages\pip\_vendor\urllib3\response.py", line 440, 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 --default-timeout=100 install -U 库名

如下:

(datasci) C:\Users\德玛西亚>pip --default-timeout=100 install -U pandas==1.1.3
Collecting pandas==1.1.3
  Downloading pandas-1.1.3-cp38-cp38-win_amd64.whl (8.9 MB)
     ---------------------------------------- 8.9/8.9 MB 106.0 kB/s eta 0:00:00
Collecting python-dateutil>=2.7.3
  Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
     ---------------------------------------- 247.7/247.7 kB 81.3 kB/s eta 0:00:00
Collecting numpy>=1.15.4
  Downloading numpy-1.23.3-cp38-cp38-win_amd64.whl (14.7 MB)
     ---------------------------------------- 14.7/14.7 MB 221.0 kB/s eta 0:00:00
Collecting pytz>=2017.2
  Downloading pytz-2022.2.1-py2.py3-none-any.whl (500 kB)
     ---------------------------------------- 500.6/500.6 kB 275.3 kB/s eta 0:00:00
Collecting six>=1.5
  Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Installing collected packages: pytz, six, numpy, python-dateutil, pandas
Successfully installed numpy-1.23.3 pandas-1.1.3 python-dateutil-2.8.2 pytz-2022.2.1 six-1.16.0

(datasci) C:\Users\德玛西亚>

完美解决!!!!

你可能感兴趣的:(python,pandas,开发语言)