Python 使用 Anaconda 安装 pygame
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19636480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installation of pygame with Anaconda
提问by radhanila
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/condaAs 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".
我有Anaconda 1.6.2
,它使用Python 2.7.5
,安装在Windows 7 64-bit
系统上。
我需要安装Pygame 1.9.1
,这不是conda repository
.
我无法运行,Windows installer
因为Anaconda
尚未为其创建注册表项,Python
并且.msi
无法识别 Python 版本。
所以,我尝试Pygame
从源代码安装。我最初想做的是按照此处的说明创建一个 conda 包http://www.continuum.io/blog/conda根据这些说明,首先从源代码安装该包(在本例中为 pygame),然后是conda 包已创建。但是,我在 pygame 安装中失败了。
在运行setup.py
文件时("python setup.py install")
,"mingw32: required environment variable MINGW_ROOT_DIRECTORY not set"
会抛出运行时错误。
设置环境变量后,我再次运行安装程序,这一次,运行时错误变为“依赖项已链接到 Python 2.7 的错误 C 运行时”。
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
distutils.cfg
\Anaconda\Lib\distutils 中的文件读取
[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.
请告诉我安装Pygame with Anaconda
. 我无法找到有关此组合的任何信息(几乎没有)。我只想补充一点,当我安装了 Python 2.7.5 时,Pygame 最初是可以工作的。当我卸载原始 Python 安装并移至 Anaconda 时,问题出现了。
Thank you!
谢谢!
回答by Peihui
Another way to do the job, as i see, is to reinstall Anaconda using its Windows installer so that later you can install your pygame using Windows installer too. This could save your much work in installer pygame from source.
正如我所见,完成这项工作的另一种方法是使用其 Windows 安装程序重新安装 Anaconda,以便稍后您也可以使用 Windows 安装程序安装您的 pygame。这可以从源代码中节省您在安装程序 pygame 中的大量工作。
Note that the versions of your Anaconda and pygame should be both 32 or 64 bits, and be using the same python version.
请注意,您的 Anaconda 和 pygame 的版本应该都是 32 位或 64 位,并且使用相同的 Python 版本。
回答by alecardv
The easiest way to install Python using conda is:
使用 conda 安装 Python 的最简单方法是:
conda install -c https://conda.binstar.org/krisvanneste pygame
conda install -c https://conda.binstar.org/krisvanneste pygame
Edit (03/2016):
编辑(03/2016):
It seems like the package is unavailable, but you can use this instead:
该软件包似乎不可用,但您可以改用它:
conda install -c https://conda.anaconda.org/tlatorre python
conda install -c https://conda.anaconda.org/tlatorre python
Edit (01/2017)
编辑 (01/2017)
The command has changed, now you can use:
命令已更改,现在您可以使用:
conda install -c tlatorre pygame=1.9.2
conda install -c tlatorre pygame=1.9.2
Edit (07/2018)
编辑 (07/2018)
tlatorre's repo is still valid but a little bit outdated, you can use cogsci repo if you want the latest version:
tlatorre 的 repo 仍然有效但有点过时,如果你想要最新版本,你可以使用 cogsci repo:
conda install -c cogsci pygame
conda install -c cogsci pygame
回答by Sruthi Kurada
For anyone with a Linux computer I found a link that might be helpful:
对于任何拥有 Linux 计算机的人,我找到了一个可能有用的链接:
https://anaconda.org/tlatorre/pygame
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
然后关闭Spyder并重新启动它
回答by Gerry Laureys
In the Anaconda menu, choose Tools, then "open command prompt".
在 Anaconda 菜单中,选择工具,然后选择“打开命令提示符”。
The cmd window will open inside Anaconda. Now type "pip install pygame".
cmd 窗口将在 Anaconda 中打开。现在输入“pip install pygame”。
回答by Ben2209
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/
在 MacOs 10.12 上使用 anaconda python 3 我遵循以下程序并且它有效: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:
我只跳过了以下行,因为 pip 已经通过 anaconda 安装了:
/usr/local/share/python3/easy_install pip
回答by Vishwas Gagrani
This worked for me on windows :
这在 Windows 上对我有用:
conda install -c cogsci pygame=1.9.2a0
This didnot work for me on windows machine :
这在 Windows 机器上对我不起作用:
conda install -c tlatorre pygame=1.9.2
回答by iRobert
The following works with Anaconda2 on Win7 (32bit).
以下适用于 Win7(32 位)上的 Anaconda2。
conda install -c cogsci pygame=1.9.2
回答by Devin Collins
Using Jupyter Notebook 5.5.0 and running "install pygame" without the pip command allowed for the installation of pygame 1.9.3 for Python 3.6.5 on windows
使用 Jupyter Notebook 5.5.0 并在没有 pip 命令的情况下运行“安装 pygame”,允许在 Windows 上为 Python 3.6.5 安装 pygame 1.9.3
回答by Ch. Arham
This worked for me:
这对我有用:
- Open Anaconda Prompt (from Start Menu > Anaconda3)
- Type command 'pip install pygame'
- Open Spyder and import pygame
- 打开 Anaconda Prompt(从开始菜单 > Anaconda3)
- 输入命令' pip install pygame'
- 打开 Spyder 并导入 pygame
It should work.
它应该工作。