Pip3安装pygame不起作用

时间:2018-08-10 19:45:50

标签: installation pip pygame

我有一台运行OS X 10.6的Macbook,我正在尝试使用pip3 install pygame安装pygame。

使用python 3.7和pip 18.0。

下面是控制台中的错误。

Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/Z6/Z6RVS9IMHG4+tkl202dsTU+++TM/-Tmp-/pip-install-ftjsil2g/pygame/setup.py", line 609, in <module>
        setup(**PACKAGEDATA)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/install.py", line 545, in run
        self.run_command('build')
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build.py", line 135, in run
        self.run_command(cmd_name)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 78, in run
        _build_ext.run(self)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/command/build_ext.py", line 309, in run
        customize_compiler(self.compiler)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/sysconfig.py", line 170, in customize_compiler
        _osx_support.customize_compiler(_config_vars)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_osx_support.py", line 418, in customize_compiler
        _find_appropriate_compiler(_config_vars)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/_osx_support.py", line 191, in _find_appropriate_compiler
        "Cannot locate working compiler")
    SystemError: Cannot locate working compiler

Command "/Library/Frameworks/Python.framework/Versions/3.7/bin/python3 -u -c "import setuptools, tokenize;__file__='/private/var/folders/Z6/Z6RVS9IMHG4+tkl202dsTU+++TM/-Tmp-/pip-install-ftjsil2g/pygame/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/Z6/Z6RVS9IMHG4+tkl202dsTU+++TM/-Tmp-/pip-record-vgz3goci/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/Z6/Z6RVS9IMHG4+tkl202dsTU+++TM/-Tmp-/pip-install-ftjsil2g/pygame/

编辑:固定格式!

2 个答案:

答案 0 :(得分:0)

因此,我不完全理解您的错误消息的内容,但我建议您阅读这篇文章,因为它涵盖了在Mac OSX 10.6-10.9上很好地设置Pygame的过程。

http://brysonpayne.com/2015/01/10/setting-up-pygame-on-a-mac/

如果上述方法无效,请按照以下说明进行操作。


注意:我将介绍所有步骤,所以只需跳过您已经完成的步骤

第1步:安装Python 3和Pip

在此处下载Python 3.7:Python 3.7.0

运行安装程序,并确保选择pip(我不记得这是否是可选的)。

第2步:安装Pygame

运行以下命令以使用pip安装Pygame:

python3 -m pip install -U pygame --user

第3步:测试Pygame安装

运行此命令以测试Pygame是否正确安装:

python3 -m pygame.examples.aliens

答案 1 :(得分:0)

目前,2020年5月1日,您无法通过pip install pygame在python 3.8中安装pygame库,但可以将其安装为特定版本,仍供开发人员使用。

您可以使用以下版本在命令行中安装Python 3.8:

*pip install pygame==2.0.0.dev6*

最新版本:

*pip install pygame==2.0.0.dev10*

您可以使用 终端:

$ python3
>>import pygame
pygame 2.0.0.dev10 (SDL 2.0.12, python 3.8.2)
Hello from the pygame community. https://www.pygame.org/contribute.html