如何在Windows 7 (64位)上安装Pygame?我试了我能想到的所有方法,但都不管用。
我运行的是CPython 2.7.3 32位。
通过pip install pygame从cmd安装失败,出现错误(是的,我已安装MinGW )
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "c:\users\r\appdata\local\temp\pip-build-R\pygame\setup.py", line 325, in
run
"mingw32: required environment variable"
RuntimeError: mingw32: required environment variable MINGW_ROOT_DIRECTORY not se
t
----------------------------------------
Command C:\Python27\python.exe -c "import setuptools;__file__='c:\\users\\r\\app
data\\local\\temp\\pip-build-R\\pygame\\setup.py';exec(compile(open(__file__).re
ad().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\r\appd
ata\local\temp\pip-vi1djm-record\install-record.txt --single-version-externally-
managed failed with error code 1 in c:\users\r\appdata\local\temp\pip-build-R\py
game 在设置MINGW_ROOT_DIRECTORY=C:\MinGW并再次尝试之后,我得到了错误
Downloading/unpacking pygame
Running setup.py egg_info for package pygame
WARNING, DLL for smpeg library not found.
WARNING, DLL for tiff library not found.
WARNING, DLL for SDL_ttf library not found.
WARNING, DLL for SDL_image library not found.
WARNING, DLL for vorbisfile library not found.
WARNING, DLL for jpeg library not found.
WARNING, DLL for vorbis library not found.
WARNING, DLL for SDL_mixer library not found.
WARNING, DLL for png library not found.
WARNING, DLL for SDL library not found.
WARNING, DLL for ogg library not found.
WARNING, DLL for z library not found.
WARNING, DLL for portmidi library not found.
warning: no files found matching 'readme.txt'
no previously-included directories found matching '*\CVS'
no previously-included directories found matching '*\*\CVS'
Installing collected packages: pygame
Running setup.py install for pygame
WARNING, DLL for smpeg library not found.
WARNING, DLL for tiff library not found.
WARNING, DLL for SDL_ttf library not found.
WARNING, DLL for SDL_image library not found.
WARNING, DLL for vorbisfile library not found.
WARNING, DLL for jpeg library not found.
WARNING, DLL for vorbis library not found.
WARNING, DLL for SDL_mixer library not found.
WARNING, DLL for png library not found.
WARNING, DLL for SDL library not found.
WARNING, DLL for ogg library not found.
WARNING, DLL for z library not found.
WARNING, DLL for portmidi library not found.
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\r\appdata\local\temp\pip-build-R\pygame\setup.py", line 491
, in <module>
setup(**PACKAGEDATA)
File "C:\Python27\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\distribute-0.6.38-py2.7.egg\setuptools
\command\install.py", line 53, in run
return _install.run(self)
File "C:\Python27\lib\distutils\command\install.py", line 563, in run
self.run_command('build')
File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\distutils\command\build.py", line 127, in run
self.run_command(cmd_name)
File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "c:\users\r\appdata\local\temp\pip-build-R\pygame\setup.py", line 352
, in run
sys.version_info[:2])
RuntimeError: The dependencies are linked to the wrong C runtime for Python
2.7
Complete output from command C:\Python27\python.exe -c "import setuptools;__
file__='c:\\users\\r\\appdata\\local\\temp\\pip-build-R\\pygame\\setup.py';exec(
compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install
--record c:\users\r\appdata\local\temp\pip-xe1cpi-record\install-record.txt --s
ingle-version-externally-managed:
WARNING, DLL for smpeg library not found.
WARNING, DLL for tiff library not found.
WARNING, DLL for SDL_ttf library not found.
WARNING, DLL for SDL_image library not found.
WARNING, DLL for vorbisfile library not found.
WARNING, DLL for jpeg library not found.
WARNING, DLL for vorbis library not found.
WARNING, DLL for SDL_mixer library not found.
WARNING, DLL for png library not found.
WARNING, DLL for SDL library not found.
WARNING, DLL for ogg library not found.
WARNING, DLL for z library not found.
WARNING, DLL for portmidi library not found.
running install
running build
running build_py
running build_ext
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\r\appdata\local\temp\pip-build-R\pygame\setup.py", line 491, in
<module>
setup(**PACKAGEDATA)
File "C:\Python27\lib\distutils\core.py", line 152, in setup
dist.run_commands()
File "C:\Python27\lib\distutils\dist.py", line 953, in run_commands
self.run_command(cmd)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\site-packages\distribute-0.6.38-py2.7.egg\setuptools\com
mand\install.py", line 53, in run
return _install.run(self)
File "C:\Python27\lib\distutils\command\install.py", line 563, in run
self.run_command('build')
File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "C:\Python27\lib\distutils\command\build.py", line 127, in run
self.run_command(cmd_name)
File "C:\Python27\lib\distutils\cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "C:\Python27\lib\distutils\dist.py", line 972, in run_command
cmd_obj.run()
File "c:\users\r\appdata\local\temp\pip-build-R\pygame\setup.py", line 352, in
run
sys.version_info[:2])
RuntimeError: The dependencies are linked to the wrong C runtime for Python 2.7
----------------------------------------
Command C:\Python27\python.exe -c "import setuptools;__file__='c:\\users\\r\\app
data\\local\\temp\\pip-build-R\\pygame\\setup.py';exec(compile(open(__file__).re
ad().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\r\appd
ata\local\temp\pip-xe1cpi-record\install-record.txt --single-version-externally-
managed failed with error code 1 in c:\users\r\appdata\local\temp\pip-build-R\py
game
Storing complete log in C:\Users\R\pip\pip.log二进制安装程序也不起作用。当我尝试运行安装程序时,菜单显示"Python从另一个位置-整个功能将不可用“。如果我继续,安装将成功完成,但是尝试导入Pygame时仍然显示没有这样的模块。我不确定是它安装失败了,还是它确实安装了,但没有正确更新路径,或者是什么,但无论哪种方式,它都不能工作。
我能做什么?我无计可施了。
发布于 2013-10-14 02:53:06
几个月前,我在安装其他库时遇到了完全不同的问题(可能是PyTables)。我找到了一个很棒的(但非官方的)资源,用于Python库here的Windows二进制文件。我能够毫无问题地安装这些二进制文件中的相当多。
如果你想解决这个问题,我建议你去看看setup.py的源代码(第345行):
def run(self):
"""Extended to set MINGW_ROOT_DIRECTORY, PATH and LIBRARY_PATH"""
if self.compiler in mingw32_compilers:
# Add MinGW environment variables.
if 'MINGW_ROOT_DIRECTORY' not in os.environ:
# Use MinGW setup conifiguration file if present.
import mingwcfg
try:
mingw_root = mingwcfg.read()
except IOError:
raise RuntimeError(
"mingw32: required environment variable"
" MINGW_ROOT_DIRECTORY not set")
os.environ['MINGW_ROOT_DIRECTORY'] = mingw_root
path = os.environ['PATH']
os.environ['PATH'] = ';'.join([os.path.join(mingw_root, 'bin'),
path])
if sys.version_info >= (2, 6):
# The Visual Studio 2008 C library is msvcr90.dll.
c_runtime_path = os.path.join(self.__sdl_lib_dir, 'msvcr90')
elif sys.version_info >= (2, 4):
# The Visual Studio 2003 C library is msvcr71.dll.
c_runtime_path = os.path.join(self.__sdl_lib_dir, 'msvcr71')
else:
# The Visual Studio 6.0 C library is msvcrt.dll,
# the MinGW default.
c_runtime_path = ''
if c_runtime_path and os.path.isdir(c_runtime_path):
# Override the default msvcrt.dll linkage.
os.environ['LIBRARY_PATH'] = c_runtime_path
elif not (c_runtime_path or
glob.glob(os.path.join(self.__sdl_lib_dir,
'msvcr*'))):
pass
else:
raise RuntimeError("The dependencies are linked to"
" the wrong C runtime for"
" Python %i.%i" %
sys.version_info[:2]初步看来,问题似乎是您没有最新的Microsoft Visual C++运行时,可以从here下载该运行时。希望这能有所帮助。
发布于 2016-01-26 20:05:16
如果您在安装pygame时遇到问题,则会出现有关缺少visual studio 10+错误。我有答案:问题不是有没有visual studio,因为我尝试了很多版本,但都不起作用。问题是文件:在tar.gz和.whl之间,这是解决方案:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame
在这里下载你的x86版本,注意x64或者python的版本。我的系统是x64,Python3.4,所以我选择: pygame-1.9.2a0-cp34-none-win_amd64.whl
我把它放在"C:“中,所以打开cmd并输入:
cd C:\
(这是将位置更改为C:)
pip安装C:\pygame-1.9.2a0-cp34-none-win_amd64.whl
完成了!
https://stackoverflow.com/questions/19348655
复制相似问题