Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Windows 7上安装Pygame?_Python_Windows_Pygame - Fatal编程技术网

Python 如何在Windows 7上安装Pygame?

Python 如何在Windows 7上安装Pygame?,python,windows,pygame,Python,Windows,Pygame,如何在64位Windows 7上安装Pygame?我已经尝试了我能想到的一切,但没有任何效果 我正在运行CPython 2.7.3 32位 通过pip从cmd安装pygame失败,错误为yes I have MinGW installed File "C:\Python27\lib\distutils\dist.py", line 972, in run_command cmd_obj.run() File "c:\users\r\appdata\local\temp\pip

如何在64位Windows 7上安装Pygame?我已经尝试了我能想到的一切,但没有任何效果

我正在运行CPython 2.7.3 32位

通过pip从cmd安装pygame失败,错误为yes I have MinGW installed

  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\u ROOT\u 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时仍然表示没有此类模块。我不确定它是否安装失败,或者它是否确实安装了,但没有更新正确的路径,或者是什么,但无论如何它都不工作


我能做什么?我已经束手无策了。

我在安装其他图书馆时遇到了完全不同的问题,几个月前可能是PyTables。我发现了一个很棒但非官方的Python库Windows二进制文件资源。我能够安装很多这样的二进制文件而没有问题

如果您希望解决此问题,我建议您访问setup.pyline 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]

在初步的外观上,问题似乎是你没有最新的微软VisualC++运行时,你可以从中下载。希望这对您有所帮助。

如果您在安装pygame时遇到问题,请参阅有关缺少visual studio 10+的错误。我有答案:问题不在于有没有VisualStudio,因为我尝试了很多版本,但都不管用。问题在于tar.gz和.whl之间的文件:因此,解决方案如下:

下载文件:

到这里下载pygame版本,注意x64或x86和python版本。我的系统是x64,python是3.4,所以我选择:pygame-1.9.2a0-cp34-none-win_amd64.whl

将其放在一些要安装的位置:

我把它放在C:,所以打开cmd并键入:

cd C:\ 
这是将位置更改为C:

安装


完成了

你是如何安装Python的?您是否使用了python.org上的安装程序?你在尝试什么pygame二进制安装程序?@Bren是的,我使用了python.org上的安装程序。我使用的pygame安装程序是来自的win32-py2.7 MSI,我尝试了两者。当我尝试安装MSVC++运行时,它说我已经安装了更新版本。我最终使用了非官方的安装程序。很遗憾,官方的安装程序似乎不起作用。在windows中用python安装一些库是一件非常痛苦的事情,即使使用pip和easy_安装也是如此。我花了将近3天的时间试图安装PyMC,然后才求助于上面的链接。尽管如此,也请向PyGame社区咨询您所面临的问题。非官方的二进制文件很棒,但是如果安装程序中的任何潜在问题也在官方版本中得到解决,对社区来说会更好。
pip install C:\pygame-1.9.2a0-cp34-none-win_amd64.whl