我一直在努力寻找正确的研究来安装pygame大约2天,并想请社区寻求解决方案!
我的MacBook是旧MacBook的备份,所以如果这是问题的本质,我愿意接受修复建议!
在安装方面
donners-mbp-2:~ Donner$ /usr/local/share/python/pip install hg+http://bitbucket.org/pygame/pygame
donners-mbp-2:~ Donner$ /usr/local/share/python/pip: No such file or directory
经过研究我应该在终端中使用此代码进行安装,但是我收到以下错误消息:
donners-mbp-2:~ Donner$ sudo -H pip install hg+http://bitbucket.org/pygame/pygame
Password:
Collecting hg+http://bitbucket.org/pygame/pygame
Cloning hg http://bitbucket.org/pygame/pygame to /private/tmp/pip-SqL4BW-build
Requirement already satisfied (use --upgrade to upgrade): pygame==1.9.4.dev0 from hg+http://bitbucket.org/pygame/pygame in /usr/local/lib/python2.7/site-packages
查看我的“主页”目录 - AKA Macintosh HD - 我的库目录不在我的用户文件夹中(直接在主HD上的AKA)。
我应该将其移至我的用户文件夹,然后重试吗?
在运行pygame安装时,这是我命令行上的内容。
#!/usr/bin/env python
import pygame
执行以下文件时:
/Users/Donner/Desktop/Python/komodo/pygame/pygame1/open_script ; exit;
donners-mbp-2:~ Donner$ /Users/Donner/Desktop/Python/komodo/pygame/pygame1/open_script ; exit;
Traceback (most recent call last):
File "pygame1.py", line 3, in <module>
import pygame
ImportError: No module named pygame
logout
[Process completed]
错误是:
donners-mbp-2:~ Donner$ brew doctor
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.
Unexpected header files:
/usr/local/include/python2.7/pygame/_camera.h
/usr/local/include/python2.7/pygame/_pygame.h
/usr/local/include/python2.7/pygame/_surface.h
/usr/local/include/python2.7/pygame/bitmask.h
/usr/local/include/python2.7/pygame/camera.h
/usr/local/include/python2.7/pygame/fastevents.h
/usr/local/include/python2.7/pygame/font.h
/usr/local/include/python2.7/pygame/freetype.h
/usr/local/include/python2.7/pygame/mask.h
/usr/local/include/python2.7/pygame/mixer.h
/usr/local/include/python2.7/pygame/pgarrinter.h
/usr/local/include/python2.7/pygame/pgbufferproxy.h
/usr/local/include/python2.7/pygame/pgcompat.h
/usr/local/include/python2.7/pygame/pgopengl.h
/usr/local/include/python2.7/pygame/pygame.h
/usr/local/include/python2.7/pygame/scrap.h
/usr/local/include/python2.7/pygame/surface.h
Warning: You are using macOS 10.9.
We (and Apple) do not provide support for this old version.
You may encounter build failures or other breakages.
Please create pull-requests instead of filing issues.
Warning: /usr/bin occurs before /usr/local/bin
This means that system-provided programs will be used instead of those
provided by Homebrew. The following tools exist at both paths:
2to3
2to3-2.7
easy_install
easy_install-2.7
git
git-cvsserver
git-receive-pack
git-shell
git-upload-archive
git-upload-pack
idle
idle2.7
pydoc
pydoc2.7
python
python-config
python2.7
python2.7-config
pythonw
pythonw2.7
smtpd.py
smtpd2.7.py
Consider setting your PATH so that /usr/local/bin
occurs before /usr/bin. Here is a one-liner:
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
编辑:我在终端做了一名酿酒医生并收到了这个作为输出。
{{1}}
感谢您提供任何帮助/建议!
答案 0 :(得分:0)
(代表OP发布)。
这已经解决了。
我按照这个来显示$ PATH中的隐藏文件并建立一个新的$ PATH。 https://coolestguidesontheplanet.com/add-shell-path-osx/
然后按照此处的评论取消安装并重新安装pygame:https://www.reddit.com/r/Python/comments/2jfj1w/how_to_install_pygame_on_osx_1095/。特别是redditor PigBoyOhBoy的评论(对Python 2.7而不是Python 3进行了一些调整)。