pygame 在 mac os 中的安装问题
- 2024-11-22 08:47:00
- admin 原创
- 190
问题描述:
我在安装 pygame 包时遇到以下问题。
In file included from src/_numericsurfarray.c:23:
src/pygame.h:106:10: fatal error: 'SDL.h' file not found
#include <SDL.h>
^
1 error generated.
error: Setup script exited with error: command 'gcc' failed with exit status 1
系统信息
Mac OS-10.9.2
python 版本-Python 2.7.5 :: Anaconda 1.6.1(x86_64)
如有任何建议,我们将不胜感激。谢谢。
解决方案 1:
在这里(OSX Mavericks)我可以通过以下方式安装:
brew install sdl sdl_image sdl_mixer sdl_ttf portmidi
pip install https://bitbucket.org/pygame/pygame/get/default.tar.gz
(“默认”分支现在处于提交e3ae850上)
来源:https://bitbucket.org/pygame/pygame/issue/139/sdlh-not-found-even-thought-it-exists#comment-3822470
另请参阅此其他 StackOverflow 问题:在 OS X 上使用 brew 在虚拟环境中使用 PyGame?
解决方案 2:
我遇到了同样的问题。我尝试了这个问题的所有版本的答案,包括 pip 和 pip3 的变体。最后,对我有用的是:
sudo easy_install pygame
但请注意:(1)https://setuptools.readthedocs.io/en/latest/easy_install.html说 easy_install 已被弃用并建议使用 pip。(2)pygame 安装在旧的标准 python 2.7 文件夹中,而不是我刚刚安装的 python 3.8.3 中——尽管我能够在 VSCode 中成功使用它。
解决方案 3:
我的系统也是OSX10.9.2,也遇到了你的问题,我还在尝试一些;也许这对你有帮助:
有一些步骤:
1.Install [Quartz](https://xquartz.macosforge.org/landing/);
2.Install Xcode-Command-Line,
but you may cant install it by `xcode-select --install`,
so you can down from
https://developer.apple.com/downloads/index.action ;
I suggest you setup xcode,and this really solute my some problem;
3.`brew tap homebrew/headonly`
`brew install smpeg --HEAD`
`brew install sdl sdl_image sdl_mixer sdl_ttf portmidi`
4. `sudo pip install hg+http://bitbucket.org/pygame/pygame`;
if you clone this repo and try `python setup.py install`,you may meet some weird problem;
我尝试安装基于 pygame 的 kivy,并尝试了很多次,但只成功安装了一次 pygame。然后我卸载了它,仍然无法安装它 ;(
一些参考:
http://jamesfriend.com.au/installing-pygame-python-mac-os-108-mountain-lion
http://juliaelman.com/blog/2013/04/02/installing-pygame-on-osx-mountain -狮子/
=======更新
现在我已经成功安装了 pygmae,记住你应该安装 xcode,而不仅仅是 xcode-command-line!
解决方案 4:
我使用以下命令在 Mac OSX 10.14.4 上安装了 pygame:
brew 安装 sdl sdl_image sdl_mixer sdl_ttf portmidi sudo -H pip3.8 安装 pygame
解决方案 5:
这对我有用:
如果您尚未通过 homebrew 安装 Python/pip(您正在使用系统安装的 Python),您可能需要运行 sudo pip3 install pygame。
在运行 pip3 install pygame 之前,我还安装了 XCode 的命令行工具)以及 XQuartz,以及以下自制包:brew install sdl sdl_image sdl_mixer sdl_ttf smpeg portmidi。
如果 homebrew 无法安装 smpeg,您可能需要执行以下操作:
brew tap homebrew/headonly brew install --HEAD smpeg
来源: http: //jamesfriend.com.au/installing-pygame-python-mac-os-108-mountain-lion