Installation of pygame with Anaconda

2020-02-10 03:07发布

I have Anaconda 1.6.2, which uses Python 2.7.5, installed on a Windows 7 64-bit system.
I need to install Pygame 1.9.1 and this is not part of the conda repository.
I cannot run the Windows installer because Anaconda has not made registry entries for Python and the .msi does not recognize the Python version.
So, I tried to install Pygame from source. What I originally wanted to do was create a conda package as per the instructions here http://www.continuum.io/blog/conda As per those instructions, the package (pygame in this case) is first installed from source and then a conda package is created. But, I failed in the pygame install.
On running the setup.py file ("python setup.py install"), a run time error
"mingw32: required environment variable MINGW_ROOT_DIRECTORY not set" is thrown.
After setting the environment variables, I ran the setup again and this time, the runtime error became "The dependencies are linked to the wrong C runtime for Python 2.7".

Error:

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 "setup.py", line 491, in <module>
    setup(**PACKAGEDATA)
  File "C:\Anaconda\lib\distutils\core.py", line 152, in setup
    dist.run_commands()
  File "C:\Anaconda\lib\distutils\dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "C:\Anaconda\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Anaconda\lib\distutils\command\install.py", line 563, in run
    self.run_command('build')
  File "C:\Anaconda\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Anaconda\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "C:\Anaconda\lib\distutils\command\build.py", line 127, in run
    self.run_command(cmd_name)
  File "C:\Anaconda\lib\distutils\cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "C:\Anaconda\lib\distutils\dist.py", line 972, in run_command
    cmd_obj.run()
  File "setup.py", line 352, in run
    sys.version_info[:2])
RuntimeError: The dependencies are linked to the wrong C runtime for Python 2.7

The distutils.cfg file in \Anaconda\Lib\distutils reads

[build]
compiler = mingw32

Please tell me what I need to do to install Pygame with Anaconda. I'm not able to find any information (barely any) regarding this combination. I would just like to add that Pygame was originally working when I had a Python 2.7.5 installation. The problem has come up now when I uninstalled my original Python installation and moved to Anaconda.

Thank you!

9条回答
一夜七次
2楼-- · 2020-02-10 03:16

The following works with Anaconda2 on Win7 (32bit).

conda install -c cogsci pygame=1.9.2
查看更多
Viruses.
3楼-- · 2020-02-10 03:18

With anaconda python 3 on MacOs 10.12 I followed the following procedure and it worked : http://florian-berger.de/en/articles/installing-pygame-for-python-3-on-os-x/

I only skipped the following line since pip was already installed through anaconda:

/usr/local/share/python3/easy_install pip
查看更多
smile是对你的礼貌
4楼-- · 2020-02-10 03:21

This worked for me on windows :

conda install -c cogsci pygame=1.9.2a0

This didnot work for me on windows machine :

conda install -c tlatorre pygame=1.9.2
查看更多
forever°为你锁心
5楼-- · 2020-02-10 03:25

In the Anaconda menu, choose Tools, then "open command prompt".

The cmd window will open inside Anaconda. Now type "pip install pygame".

查看更多
家丑人穷心不美
6楼-- · 2020-02-10 03:32

The easiest way to install Python using conda is:

conda install -c https://conda.binstar.org/krisvanneste pygame

Edit (03/2016):

It seems like the package is unavailable, but you can use this instead:

conda install -c https://conda.anaconda.org/tlatorre python

Edit (01/2017)

The command has changed, now you can use:

conda install -c tlatorre pygame=1.9.2

Edit (07/2018)

tlatorre's repo is still valid but a little bit outdated, you can use cogsci repo if you want the latest version:

conda install -c cogsci pygame

查看更多
Luminary・发光体
7楼-- · 2020-02-10 03:33

For anyone with a Linux computer I found a link that might be helpful:

https://anaconda.org/tlatorre/pygame

run this command in your terminal :

conda install -c tlatorre pygame=1.9.2 

Then close Spyder and restart it

查看更多
登录 后发表回答