sauerkrautfishl 2023-01-05 00:25 采纳率: 100%
浏览 64
已结题

python安装pygame模块出现SSLCertVerificationError和URLError错误

萌新刚上手三天python,想安装一个pygame模块,学一学相关代码。结果安装失败,出现SSLCertVerificationError和URLError

 在命令行中输入pip install pygame -i https://pypi.tuna.tsinghua.edu.cn/simple

产生错误,运行结果:
C:\Users\79286>pip install pygame -i https://pypi.tuna.tsinghua.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting pygame
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/9a/50/67767e5586a45e7e7b02e6f0e07853f8fcb81b54c66db6278f1a1344491f/pygame-2.1.2.tar.gz (10.1 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [80 lines of output]


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

      Traceback (most recent call last):
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 1348, in do_open
          h.request(req.get_method(), req.selector, req.data, headers,
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1282, in request
          self._send_request(method, url, body, headers, encode_chunked)
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1328, in _send_request
          self.endheaders(body, encode_chunked=encode_chunked)
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1277, in endheaders
          self._send_output(message_body, encode_chunked=encode_chunked)
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1037, in _send_output
          self.send(msg)
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 975, in send
          self.connect()
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 1454, in connect
          self.sock = self._context.wrap_socket(self.sock,
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 517, in wrap_socket
          return self.sslsocket_class._create(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1075, in _create
          self.do_handshake()
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\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\79286\AppData\Local\Temp\pip-install-xt028uw6\pygame_b42a2ef519804802952eae4b096b2df0\setup.py", line 359, in <module>
          buildconfig.config.main(AUTO_CONFIG)
        File "C:\Users\79286\AppData\Local\Temp\pip-install-xt028uw6\pygame_b42a2ef519804802952eae4b096b2df0\buildconfig\config.py", line 225, in main
          deps = CFG.main(**kwds)
                 ^^^^^^^^^^^^^^^^
        File "C:\Users\79286\AppData\Local\Temp\pip-install-xt028uw6\pygame_b42a2ef519804802952eae4b096b2df0\buildconfig\config_win.py", line 497, in main
          and download_win_prebuilt.ask(**download_kwargs):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\79286\AppData\Local\Temp\pip-install-xt028uw6\pygame_b42a2ef519804802952eae4b096b2df0\buildconfig\download_win_prebuilt.py", line 290, in ask
          update(x86=x86, x64=x64)
        File "C:\Users\79286\AppData\Local\Temp\pip-install-xt028uw6\pygame_b42a2ef519804802952eae4b096b2df0\buildconfig\download_win_prebuilt.py", line 273, in update
          download_prebuilts(download_dir, x86=x86, x64=x64)
        File "C:\Users\79286\AppData\Local\Temp\pip-install-xt028uw6\pygame_b42a2ef519804802952eae4b096b2df0\buildconfig\download_win_prebuilt.py", line 124, in download_prebuilts
          download_sha1_unzip(url, checksum, temp_dir, 1)
        File "C:\Users\79286\AppData\Local\Temp\pip-install-xt028uw6\pygame_b42a2ef519804802952eae4b096b2df0\buildconfig\download_win_prebuilt.py", line 54, in download_sha1_unzip
          response = urllib.urlopen(request).read()
                     ^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 216, in urlopen
          return opener.open(url, data, timeout)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 519, in open
          response = self._open(req, data)
                     ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 536, in _open
          result = self._call_chain(self.handle_open, protocol, protocol +
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 496, in _call_chain
          result = func(*args)
                   ^^^^^^^^^^^
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\Lib\urllib\request.py", line 1391, in https_open
          return self.do_open(http.client.HTTPSConnection, req,
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\79286\AppData\Local\Programs\Python\Python311\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

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

查了网上教程,别人主要是下载连接超时和pip版本过旧问题。我照着换了源、更新了pip版本,仍然无法解决这些问题,求大佬帮助
  • 写回答

6条回答 默认 最新

  • Jackyin0720 2023-01-05 11:09
    关注
    error: subprocess-exited-with-error
      × python setup.py egg_info did not run successfully.
      │ exit code: 1
      ╰─> [80 lines of output]
    错误:子进程退出,出现错误
    ×python setup.py egg_info未成功运行。
    │ 退出代码:1
    ╰─> [80行输出]
    
    error: metadata-generation-failed
    × Encountered error while generating package metadata.
    ╰─> See above for output.
    错误:元数据生成失败
    ×生成包元数据时遇到错误。
    ╰─> 输出见上文。
    
    分析是版本不匹配的原因,要么是python版本过高或过低,要么是pygame过高或过低
    

    建议题主结合这个实例去安装【Python中Pygame模块的详细安装过程】,链接:https://www.jb51.net/article/263821.htm

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
  • 无得591 2023-01-05 03:11
    关注

    export HTTPS_PROXY=http://your-proxy-server:port
    pip install pygame
    如果这种方法无法解决问题,你可以尝试使用清华大学的镜像源安装模块,方法是修改 pip 的配置文件(Linux 系统下在 ~/.pip/pip.conf 中,Windows 系统下在 %APPDATA%\pip\pip.ini 中),在文件末尾加入如下内容:[global]
    index-url = https://pypi.tuna.tsinghua.edu.cn/simple
    然后再使用 pip 安装模块即可。
    如果这些方法都无法解决问题,你可以尝试使用其他安装方式,例如从源代码安装或者下载已编译的二进制包安装。
    希望这些建议能够帮助你解决问题。

    评论
  • A1358722560 2023-01-05 07:50
    关注

    有可能是加密传输有问题,可以尝试一下加入--trusted-host:
    pip install pygame -i https://pypi.org/simple --trusted-host pypi.org
    或者
    pip install pygame -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
    类似的可以把网站换位其他源

    1)http://mirrors.aliyun.com/pypi/simple/ 阿里云
    
    2)https://pypi.mirrors.ustc.edu.cn/simple/  中国科技大学
    
    3) http://pypi.douban.com/simple/  豆瓣
    
    4) https://pypi.tuna.tsinghua.edu.cn/simple/ 清华大学
    
    5)  http://pypi.mirrors.ustc.edu.cn/simple/ 中国科学技术大学
    
    
    评论
  • gnn_explorer 2023-01-05 10:35
    关注

    建议离线安装:

    1. 下载 https://anaconda.org/cleebp/pygame/2.1.2/download/win-64/pygame-2.1.2-py37_2.tar.bz2
    2. pip install pygame-2.1.2-py37_2.tar.bz2
    评论
  • 书某人.py 2023-01-05 10:14
    关注

    这边认为您是电脑无法关联镜像源,建议不使用镜像源,直接进行安装。
    在cmd中输入如下命令

    pip install pygame
    
    评论
  • wux_labs 2023-01-05 01:03
    关注

    国内镜像源推荐都试一下。

    1. 阿里 https://mirrors.aliyun.com/pypi/simple/
    2. 清华 https://pypi.tuna.tsinghua.edu.cn/simple/
    3. 豆瓣 https://pypi.douban.com/simple/
      注意这里都是 https 的,不然下载包的时候会出现其他错。
      望采纳,谢谢!
    评论
查看更多回答(5条)

报告相同问题?

问题事件

  • 系统已结题 1月13日
  • 已采纳回答 1月5日
  • 创建了问题 1月5日

悬赏问题

  • ¥15 Erasure Code纠删码表
  • ¥15 用vite创建的vue3项目,404重定向不起作用??
  • ¥15 关于#c语言#的问题:一个球从80米高度自由落下,每次落地后反弹的高度为原高度的一半计算6次小球反弹的高度.(反弹结果取整,使用走走for循环结构)
  • ¥15 SurfaceControl的screenshot问题
  • ¥15 基于51单片机的oled菜单代码,要C语言,模块化编程!
  • ¥15 JAVAswing,设计一个扑克牌什么的
  • ¥50 python ctypes调用dll实现分析
  • ¥40 用python解决数据统计问题
  • ¥100 是否有方案能通过抓包分析得到移动应用的名称和包名信息?
  • ¥15 opencv检测不到轮廓