简体   繁体   English

Python pygame 未安装

[英]Python pygame not installing

C:\Users\matth>pip3 install pygame Collecting pygame Using cached pygame-2.1.2.tar.gz (10.1 MB) Preparing metadata (setup.py)... error error: subprocess-exited-with-error C:\Users\matth>pip3 install pygame 正在收集 pygame 使用缓存的 pygame-2.1.2.tar.gz (10.1 MB) 正在准备元数据 (setup.py)... 错误 error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully. × python setup.py egg_info 没有运行成功。 │ exit code: 1 ╰─> [80 lines of output] │ 退出码:1 ╰─> 【80行输出】

  WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
  Using WINDOWS configuration...

  Traceback (most recent call last):
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1348, in do_open
      h.request(req.get_method(), req.selector, req.data, headers,
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1282, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1328, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1277, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1037, in _send_output
      self.send(msg)
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 975, in send
      self.connect()
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\http\client.py", line 1454, in connect
      self.sock = self._context.wrap_socket(self.sock,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 517, in wrap_socket
      return self.sslsocket_class._create(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1075, in _create
      self.do_handshake()
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\ssl.py", line 1346, in do_handshake
      self._sslobj.do_handshake()
  ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "<string>", line 2, in <module>
    File "<pip-setuptools-caller>", line 34, in <module>
    File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\setup.py", line 359, in <module>
      buildconfig.config.main(AUTO_CONFIG)
    File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config.py", line 225, in main
      deps = CFG.main(**kwds)
             ^^^^^^^^^^^^^^^^
    File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\config_win.py", line 497, in main
      and download_win_prebuilt.ask(**download_kwargs):
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 290, in ask
      update(x86=x86, x64=x64)
    File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 273, in update
      download_prebuilts(download_dir, x86=x86, x64=x64)
    File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 124, in download_prebuilts
      download_sha1_unzip(url, checksum, temp_dir, 1)
    File "C:\Users\matth\AppData\Local\Temp\pip-install-g18yr5c2\pygame_2c1b94c764cc404881a71cf0ac51d63e\buildconfig\download_win_prebuilt.py", line 54, in download_sha1_unzip
      response = urllib.urlopen(request).read()
                 ^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 216, in urlopen
      return opener.open(url, data, timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 519, in open
      response = self._open(req, data)
                 ^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 536, in _open
      result = self._call_chain(self.handle_open, protocol, protocol +
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 496, in _call_chain
      result = func(*args)
               ^^^^^^^^^^^
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1391, in https_open
      return self.do_open(http.client.HTTPSConnection, req,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.193.0_x64__qbz5n2kfra8p0\Lib\urllib\request.py", line 1351, in do_open
      raise URLError(err)
  urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)>
  Making dir :prebuilt_downloads:
  Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip ed561079ec622b0bab5a9e02976f5d540b0622da

  ---
  For help with compilation see:
      https://www.pygame.org/wiki/CompileWindows
  To contribute to pygame development see:
      https://www.pygame.org/contribute.html
  ---

  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed注意:此错误源自子进程,可能不是 pip 的问题。错误:元数据生成失败

× Encountered error while generating package metadata. × 生成 package 元数据时遇到错误。 ╰─> See above for output. ╰─> output见上。

note: This is an issue with the package mentioned above, not pip. hint: See above for details.注意:这是上面提到的 package 的问题,而不是 pip。提示:详情见上文。

Short answer简答

pip install pygame --pre is necessary right now due to your Python version由于您的 Python 版本,现在需要pip install pygame --pre

Long answer长答案

Your traceback shows you are using Python 3.11, which was just released earlier today.您的回溯显示您正在使用今天早些时候刚刚发布的 Python 3.11。 Pygame is a "C extension" and needs to re-release itself with new "wheels" (binaries) for every new minor release of Python (3.9, 3.10, 3.11, etc.) Pygame 是一个“C 扩展”,需要为每个新的 Python 次要版本(3.9、3.10、3.11 等)重新发布新的“轮子”(二进制文件)

The latest "full" pygame release, 2.1.2, was released a while back and doesn't come with wheels for 3.11, so your system tries to build pygame from source.最新的“完整”pygame 版本 2.1.2 已发布一段时间,并且不附带 3.11 的轮子,因此您的系统会尝试从源代码构建 pygame。 It fails to do so, because you don't have a pygame development environment set up.它没有这样做,因为你没有设置 pygame 开发环境。

However, the latest pre release of pygame, 2.1.3.dev8 (released recently) has wheels for 3.11, so your system will not need to compile pygame from source.但是,pygame 的最新预发布版本 2.1.3.dev8(最近发布)具有适用于 3.11 的轮子,因此您的系统不需要从源代码编译 pygame。

Once pygame 2.1.3 is released, this extra flag (which tells it to look for pre releases), won't be necessary.一旦 pygame 2.1.3 发布,这个额外的标志(告诉它寻找预发布版本)就不再需要了。

Install python 3.10 and wait for pygame to be ready for 3.11 and then install pygame for that version.安装 python 3.10 并等待 pygame 为 3.11 做好准备,然后为该版本安装 pygame。 You can also have 2 version of python installed.您还可以安装 2 个版本的 python。

To work with each one use:要处理每一个,请使用:

py -3.10 script.py py -3.10 脚本.py

py -3.11 script.py py -3.11 脚本.py

If you are using poetry.如果你正在使用诗歌。 Do the following:请执行下列操作:

poetry add pygame=2.1.3.dev8

If you are using pip.如果您使用的是点子。 Do the following:请执行下列操作:

pip install pygame --pre

si vous utilisez python3.11, veuillez utiliser si vous utilisez python3.11, veuillez utiliser

pip3 install pygame --pre

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM