Python 安装pygame时遇到问题。权限Mac OS X 10.9.5
我一直在努力寻找正确的研究,以安装pygame约2天,并希望社区达成一个解决方案 我的MacBook是我旧MacBook的备份,因此如果这是问题的本质,我愿意接受修复建议 在安装方面Python 安装pygame时遇到问题。权限Mac OS X 10.9.5,python,macos,module,installation,pygame,Python,Macos,Module,Installation,Pygame,我一直在努力寻找正确的研究,以安装pygame约2天,并希望社区达成一个解决方案 我的MacBook是我旧MacBook的备份,因此如果这是问题的本质,我愿意接受修复建议 在安装方面 donners-mbp-2:~ Donner$ brew list cmake isl mercurial python smpeg freetype jpeg mpfr readline sphinx-doc
donners-mbp-2:~ Donner$ brew list
cmake isl mercurial python smpeg
freetype jpeg mpfr readline sphinx-doc
gcc libmpc numpy sdl sqlite
gdbm libpng openssl sdl_image webp
git libtiff pkg-config sdl_mixer
gmp makedepend portmidi sdl_ttf
经过研究,我应该在终端中使用此代码进行安装,但我收到以下错误消息:
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
看看我的“Home”目录——又名Macintosh HD——我的库目录不在我的用户文件夹中(又名直接在主HD上)
我是否应该将其移动到我的用户文件夹,然后重试
当运行pygame安装时,我的命令行上就是这样
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
使用以下命令执行文件时:
#!/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]
谢谢你的帮助/建议 (代表OP发布)
这个问题解决了
我按照这个步骤显示$PATH中的隐藏文件,并建立一个新的$PATH
然后卸载并重新安装pygame,如下所示:。特别是redditor PigBoyOhBoy的评论(对Python 2.7而不是Python 3进行了一些调整)。您可以
pip安装任何其他软件包吗?如果是这样的话,它会在哪里结束呢?哪个pip
说什么?Donner-mbp-2:~Donner$which pip-->/usr/local/bin/pip@9000目录路径是Macintosh HD/Donner/Users/Donner/Library/Python/2.7/lib/Python/site-packages/pip(这里有:pip、beautifulsoup和easy install)@9000替代目录路径是Macintosh HD/Library/Python/2.7/site-packages。显然,我在这两个位置都有相同的模块。您是否尝试过brew安装python
而不是系统python?(这通常是个好主意。)
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