君夕273 2022-12-01 21:11 采纳率: 100%
浏览 75
已结题

pygame安装失败

python最新版下载pygame不成功
C:\Users\lh>python -m pip 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

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

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

  Traceback (most recent call last):
    File "D:\python\Lib\urllib\request.py", line 1348, in do_open
      h.request(req.get_method(), req.selector, req.data, headers,
    File "D:\python\Lib\http\client.py", line 1282, in request
      self._send_request(method, url, body, headers, encode_chunked)
    File "D:\python\Lib\http\client.py", line 1328, in _send_request
      self.endheaders(body, encode_chunked=encode_chunked)
    File "D:\python\Lib\http\client.py", line 1277, in endheaders
      self._send_output(message_body, encode_chunked=encode_chunked)
    File "D:\python\Lib\http\client.py", line 1037, in _send_output
      self.send(msg)
    File "D:\python\Lib\http\client.py", line 975, in send
      self.connect()
    File "D:\python\Lib\http\client.py", line 1447, in connect
      super().connect()
    File "D:\python\Lib\http\client.py", line 941, in connect
      self.sock = self._create_connection(
                  ^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\python\Lib\socket.py", line 850, in create_connection
      raise exceptions[0]
    File "D:\python\Lib\socket.py", line 835, in create_connection
      sock.connect(sa)
  TimeoutError: [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。

  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\lh\AppData\Local\Temp\pip-install-0cdwv9sg\pygame_f91420ec77d54dc897404f3ec80ccb65\setup.py", line 359, in <module>
      buildconfig.config.main(AUTO_CONFIG)
    File "C:\Users\lh\AppData\Local\Temp\pip-install-0cdwv9sg\pygame_f91420ec77d54dc897404f3ec80ccb65\buildconfig\config.py", line 225, in main
      deps = CFG.main(**kwds)
             ^^^^^^^^^^^^^^^^
    File "C:\Users\lh\AppData\Local\Temp\pip-install-0cdwv9sg\pygame_f91420ec77d54dc897404f3ec80ccb65\buildconfig\config_win.py", line 497, in main
      and download_win_prebuilt.ask(**download_kwargs):
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "C:\Users\lh\AppData\Local\Temp\pip-install-0cdwv9sg\pygame_f91420ec77d54dc897404f3ec80ccb65\buildconfig\download_win_prebuilt.py", line 290, in ask
      update(x86=x86, x64=x64)
    File "C:\Users\lh\AppData\Local\Temp\pip-install-0cdwv9sg\pygame_f91420ec77d54dc897404f3ec80ccb65\buildconfig\download_win_prebuilt.py", line 273, in update
      download_prebuilts(download_dir, x86=x86, x64=x64)
    File "C:\Users\lh\AppData\Local\Temp\pip-install-0cdwv9sg\pygame_f91420ec77d54dc897404f3ec80ccb65\buildconfig\download_win_prebuilt.py", line 124, in download_prebuilts
      download_sha1_unzip(url, checksum, temp_dir, 1)
    File "C:\Users\lh\AppData\Local\Temp\pip-install-0cdwv9sg\pygame_f91420ec77d54dc897404f3ec80ccb65\buildconfig\download_win_prebuilt.py", line 54, in download_sha1_unzip
      response = urllib.urlopen(request).read()
                 ^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\python\Lib\urllib\request.py", line 216, in urlopen
      return opener.open(url, data, timeout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\python\Lib\urllib\request.py", line 519, in open
      response = self._open(req, data)
                 ^^^^^^^^^^^^^^^^^^^^^
    File "D:\python\Lib\urllib\request.py", line 536, in _open
      result = self._call_chain(self.handle_open, protocol, protocol +
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\python\Lib\urllib\request.py", line 496, in _call_chain
      result = func(*args)
               ^^^^^^^^^^^
    File "D:\python\Lib\urllib\request.py", line 1391, in https_open
      return self.do_open(http.client.HTTPSConnection, req,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "D:\python\Lib\urllib\request.py", line 1351, in do_open
      raise URLError(err)
  urllib.error.URLError: <urlopen error [WinError 10060] 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。>
  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.

img

img

  • 写回答

5条回答 默认 最新

  • Jackyin0720 2022-12-01 22:39
    关注
    
    你可看看是哪方面影响的
    No.1 python版本安装了多个【或者高低版本原因】
    方案:把多余版本删了,只留一个【降低版本或者升级版本】
    No.2 pip没有装
    方案:到pip官网安装pip
    No.3 网络问题
    方案:
    使用pip安装第三方模块时,这种问题是经常会遇到的,造成这
    种问题的原因是由于资源在境外,在连接下载时会有网速等问题
    的影响,从而造成下载超时、尝试次数超了等错误的出现。 
    解决的方法有下载离线安装包进行安装、使用国内镜像资源进行下载。
    国内的镜像源:
    https://mirrors.aliyun.com/pypi/simple/    #阿里云镜像源
    【完整命令:pip3 install pygame -i https://mirrors.aliyun.com/pypi/simple/】
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

问题事件

  • 系统已结题 12月10日
  • 已采纳回答 12月2日
  • 创建了问题 12月1日

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序