xinghanrun 2023-01-19 20:38 采纳率: 50%
浏览 60
已结题

python下载pygame时报错,如何解决?

用Macox下载pygame报错
显示错误
我输入的代码是:
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
  ╰─> [31 lines of output]
      
      
      WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
      Using Darwin configuration...
      
      /bin/sh: sdl2-config: command not found
      /bin/sh: sdl2-config: command not found
      /bin/sh: sdl2-config: command not found
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/lq/j5jdvhn93_bf8bxjkk9yd0100000gn/T/pip-install-f5dx780y/pygame_5b6d1876e3c4410b81a3ca2d9bc5a835/setup.py", line 359, in <module>
          buildconfig.config.main(AUTO_CONFIG)
        File "/private/var/folders/lq/j5jdvhn93_bf8bxjkk9yd0100000gn/T/pip-install-f5dx780y/pygame_5b6d1876e3c4410b81a3ca2d9bc5a835/buildconfig/config.py", line 225, in main
          deps = CFG.main(**kwds)
                 ^^^^^^^^^^^^^^^^
        File "/private/var/folders/lq/j5jdvhn93_bf8bxjkk9yd0100000gn/T/pip-install-f5dx780y/pygame_5b6d1876e3c4410b81a3ca2d9bc5a835/buildconfig/config_darwin.py", line 132, in main
          [DependencyProg('SDL', 'SDL_CONFIG', 'sdl2-config', '2.0', ['sdl'])],
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/private/var/folders/lq/j5jdvhn93_bf8bxjkk9yd0100000gn/T/pip-install-f5dx780y/pygame_5b6d1876e3c4410b81a3ca2d9bc5a835/buildconfig/config_unix.py", line 39, in __init__
          self.ver = config[0].strip()
                     ~~~~~~^^^
      IndexError: list index out of range
      
      ---
      For help with compilation see:
          https://www.pygame.org/wiki/MacCompile
      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.
user@UserdeMacBook-Pro ~ % 

我的解答思路和尝试过的方法:

我下载了homebrew,无效。按照pygame官网上的方法也是同样的报错

哪个大神教教我?谢谢!
  • 写回答

2条回答 默认 最新

  • Mike Qin 2023-01-19 21:39
    关注

    你的python版本是多少?目前pygame正式版只支持到python3.9

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 1月28日
  • 已采纳回答 1月20日
  • 创建了问题 1月19日

悬赏问题

  • ¥15 (标签-matlab)
  • ¥200 基于同花顺supermind的量化策略脚本编辑
  • ¥20 Html备忘录页面制作
  • ¥15 黄永刚的晶体塑性子程序中输入的材料参数里的晶体取向参数是什么形式的?
  • ¥20 数学建模来解决我这个问题
  • ¥15 计算机网络ip分片偏移量计算头部是-20还是-40呀
  • ¥15 stc15f2k60s2单片机关于流水灯,时钟,定时器,矩阵键盘等方面的综合问题
  • ¥15 YOLOv8已有一个初步的检测模型,想利用这个模型对新的图片进行自动标注,生成labellmg可以识别的数据,再手动修改。如何操作?
  • ¥30 NIRfast软件使用指导
  • ¥20 matlab仿真问题,求功率谱密度