Python命令pip install pygame安装报错

报错1如下:

Traceback (most recent call last):
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 171, in _merge_into_criterion
    crit = self.state.criteria[name]
KeyError: 'pygame'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 438, in _error_catcher
    yield
  File "c:\users\administrator\appdata\local\programs\python\python39-32\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\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\http\client.py", line 458, in read
    n = self.readinto(b)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\http\client.py", line 502, in readinto
    n = self.fp.readinto(b)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\socket.py", line 704, in readinto
    return self._sock.recv_into(b)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\ssl.py", line 1241, in recv_into
    return self.read(nbytes, buffer)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\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 "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\cli\base_command.py", line 189, in _main
    status = self.run(options, args)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\cli\req_command.py", line 178, in wrapper
    return func(self, options, args)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\commands\install.py", line 316, in run
    requirement_set = resolver.resolve(
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 121, in resolve
    self._result = resolver.resolve(
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 453, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 318, in resolve
    name, crit = self._merge_into_criterion(r, parent=None)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 173, in _merge_into_criterion
    crit = Criterion.from_requirement(self._p, requirement, parent)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 82, in from_requirement
    if not cands:
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 124, in __bool__
    return bool(self._sequence)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 99, in __bool__
    return any(self)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 237, in iter_index_candidates
    candidate = self._make_candidate_from_link(
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 165, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 300, in __init__
    super().__init__(
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 144, in __init__
    self.dist = self._prepare()
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 226, in _prepare
    dist = self._prepare_distribution()
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 311, in _prepare_distribution
    return self._factory.preparer.prepare_linked_requirement(
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\operations\prepare.py", line 457, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\operations\prepare.py", line 480, in _prepare_linked_requirement
    local_file = unpack_url(
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\operations\prepare.py", line 230, in unpack_url
    file = get_http_url(
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\operations\prepare.py", line 108, in get_http_url
    from_path, content_type = download(link, temp_dir.path)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\network\download.py", line 163, in __call__
    for chunk in chunks:
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\cli\progress_bars.py", line 159, in iter
    for x in it:
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_internal\network\utils.py", line 64, in response_chunks
    for chunk in response.raw.stream(
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 576, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\site-packages\pip\_vendor\urllib3\response.py", line 541, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\lib\contextlib.py", line 135, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\users\administrator\appdata\local\programs\python\python39-32\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.

直接看最后一行:
Read timed out

超时了,我连接的是自家的wife,所以可能慢点,不够用,所以我换了一个网络,开启手机热点再试一次:

C:\Users\Administrator>pip install pygame
Collecting pygame
  Downloading pygame-2.0.1-cp39-cp39-win32.whl (4.8 MB)
     |████████████████████████████████| 4.8 MB 1.1 MB/s
Installing collected packages: pygame
Successfully installed pygame-2.0.1

成功!

报错2如下:

(venv) D:\PyCharm\PlaneDemo>pip install pygame
Requirement already satisfied: pygame in d:\pycharm\planedemo\venv\lib\site-packages (2.0.1)
WARNING: You are using pip version 20.2.3; however, version 21.0 is available.
You should consider upgrading via the 'd:\pycharm\planedemo\venv\scripts\python.exe -m pip install --upgrade pip' command.

解决方法:(参考来自博主:翰誉华风)

首先输入命令:

python -m pip install --upgrade pip -i https://pypi.douban.com/simple

再输入命令:

pip install pygame

你可能感兴趣的:(Python,pip,install,pyg,Read,timed,out)