如何在 Python 3.4 上安装 PyGame?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28127730/
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
How to install PyGame on Python 3.4?
提问by DedSecz
So I have this little problem. When I try to install PyGame for Python 3.4 I download a .whl (wheel?) file and don't know how to use it. Some guys told me something about pip but don't know how to use/install it.
所以我有这个小问题。当我尝试为 Python 3.4 安装 PyGame 时,我下载了一个 .whl(wheel?)文件,但不知道如何使用它。有些人告诉我一些关于 pip 的事情,但不知道如何使用/安装它。
采纳答案by Malik Brahimi
You can install the wheel file for Python 3.4 here:
您可以在此处安装 Python 3.4 的轮文件:
First you have to install the wheel package from pip
then install Pygame.
首先你必须安装wheel包,pip
然后安装Pygame。
pip install wheel
pip install pygame?1.9.2a0?cp34?none?win_amd64.whl
Here's a video to help you install pip on Youtube.
这是帮助您在Youtube 上安装 pip 的视频。
回答by mchant
14 y/o? Good for you! You can put the file into your python/scripts
folder and run pip install *file*
(where *file*
is your filename).
14 岁?对你有益!您可以将文件放入python/scripts
文件夹并运行pip install *file*
(*file*
您的文件名在哪里)。
回答by StubZz
Here is a great VIDEO tutorial: http://goo.gl/PurJqk(it is on youtube)
这是一个很棒的视频教程:http: //goo.gl/PurJqk(在 youtube 上)
This is what I use to install .whl modules to python (I do this in the 64 bit windows cmd):
这是我用来将 .whl 模块安装到 python 的(我在 64 位 Windows cmd 中执行此操作):
cd "C:\Users\(YOUR USERNAME)\Desktop"
(assuming that you have the .whl file on your desktop)
(假设您的桌面上有 .whl 文件)
C:\Python34\Scripts\pip install filename.whl
(where filename.whl is the full name of the .whl file, with the .whl extension)
(其中 filename.whl 是 .whl 文件的全名,带有 .whl 扩展名)
After that it will install, and you are free to use PyGame!
之后它将安装,您就可以自由使用 PyGame!
回答by RedNax
Here is a linkto download pygame for different versions of Python, up to Python 3.4 in 32 bit and 64 bit.
这是一个下载 pygame的链接,用于下载适用于不同 Python 版本的 pygame,最高可达 32 位和 64 位的 Python 3.4。
To test if it installed properly, open your python shell and type in this code:
要测试它是否安装正确,请打开您的 python shell 并输入以下代码:
import pygame
Please note that these are not official binaries and you are basically trusting a third-party to compile and provide the binary for you.
请注意,这些不是官方二进制文件,您基本上信任第三方为您编译和提供二进制文件。
回答by Death_Dealer
https://bitbucket.org/pygame/pygame/downloads
https://bitbucket.org/pygame/pygame/downloads
"pygame-1.9.2a0-hg_5974ff8dae3c+.win32-py3.4.msi"
“pygame-1.9.2a0-hg_5974ff8dae3c+.win32-py3.4.msi”
This is the package you want, RedNax said this but did not point out the exact package.
这是你想要的包,RedNax 说了这个但没有指出确切的包。
回答by trw009
The other answer doesn't work for me on Windows 10 Pro N x64.
另一个答案在 Windows 10 Pro N x64 上对我不起作用。
What did work was installing the win32.whl instead of amd64. I put this in my Python3.4\Scripts folder where pip is and ran
什么工作是安装 win32.whl 而不是 amd64。我把它放在 pip 所在的 Python3.4\Scripts 文件夹中并运行
pip install pygame-1.9.2a0-cp34-none-win32.whl
This should work for others using a similar configuration.
这应该适用于使用类似配置的其他人。
回答by FastWilly
In my experience, you need to make sure of two things: 1) Both Python and Pygame should be 32 bit - not either or both being 64 bit. 2) Both Python and Pygame should be compatible for the same version.
根据我的经验,您需要确保两件事:1) Python 和 Pygame 都应该是 32 位的 - 不是一个或两个都是 64 位的。2) Python 和 Pygame 应该兼容同一个版本。
You may be able to get the 64 bit version to work, but not all packages have migrated to 64 bit and the small performance improvement isn't worth the frustration of trying to get it to work. I also found the latest 32 bit Pygame (as of Feb. 5th, 2016) seems to work well with 32 bit Python 3.4.4. I installed 32 bit python-3.4.4.msi on Windows 10 from my downloads folder to the folder C:\Python34. Within the Python34 folder, I created a folder called "Project Directory". In it, I placed "pygame-1.9.2a0-hg_ea3b3bb8714a.win32-py3.4.msi" which I think I got from https://bitbucket.org/pygame/pygame/downloads. Double-clicked on it. Worked the first time. I had also installed "Microsoft Visual Studio Community 2015 with Update 1." No idea if this helped solve the problem, but this MVSC package installs a lot of DLLs. It takes quite a while to get MVSC installed. But - I now have Pygame working on Windows 10.
您也许可以让 64 位版本工作,但并非所有软件包都已迁移到 64 位,并且不值得为尝试使其工作而感到沮丧。我还发现最新的 32 位 Pygame(截至 2016 年 2 月 5 日)似乎适用于 32 位 Python 3.4.4。我在 Windows 10 上从我的下载文件夹到文件夹 C:\Python34 安装了 32 位 python-3.4.4.msi。在 Python34 文件夹中,我创建了一个名为“项目目录”的文件夹。在其中,我放置了“pygame-1.9.2a0-hg_ea3b3bb8714a.win32-py3.4.msi”,我想我是从https://bitbucket.org/pygame/pygame/downloads得到的. 双击它。第一次工作。我还安装了“Microsoft Visual Studio Community 2015 with Update 1”。不知道这是否有助于解决问题,但是这个 MVSC 包安装了很多 DLL。安装 MVSC 需要很长时间。但是 - 我现在让 Pygame 在 Windows 10 上工作。
回答by MD Sijad Faisal
For linux if you root user then copy paste this into terminal
对于 linux,如果您是 root 用户,则将其复制粘贴到终端中
apt-get install python3-dev mercurial
apt-get install libsdl-image1.2-dev libsdl2-dev libsdl-ttf2.0-dev
apt-get install libsdl-mixer1.2-dev libportmidi-dev
apt-get install python-numpy
pip3 install --user hg+http://bitbucket.org/pygame/pygame
If you not root user then use sudo before start every-line.
如果您不是 root 用户,则在启动每一行之前使用 sudo。
回答by Ronaldo
Step 1
第1步
If you have not got python version 3.4.2, then you must uninstall your current version of python (or don't if you don't even have python).
如果您还没有 Python 3.4.2 版,那么您必须卸载当前版本的 Python(如果您甚至没有 Python,则不要卸载)。
Step 2
第2步
Then download and install python 3.4.2 from http://filehippo.com/download_python/58901/.
然后从http://filehippo.com/download_python/58901/下载并安装 python 3.4.2 。
Step 3
第 3 步
Follow the instructions and wait until it is ready for use.
按照说明操作并等待它准备好使用。
Step 4
第四步
Now download the 'pygame-1.9.2a0-cp34-none-win32.whl' file from http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygameand copy it into C:\Python34\Scripts .
现在从http://www.lfd.uci.edu/~gohlke/pythonlibs/#pygame下载 'pygame-1.9.2a0-cp34-none-win32.whl' 文件并将其复制到 C:\Python34\Scripts 。
Step 5
第 5 步
In C:\Python34\Scripts hold the shift key and right click. Click on 'Open new command window here'.
在 C:\Python34\Scripts 中按住 shift 键并右键单击。单击“在此处打开新的命令窗口”。
Step 6
第 6 步
In the command window you have opened, type in:
在您打开的命令窗口中,输入:
pip3 install pygame-1.9.2a0-cp34-none-win32.whl
It will say something like:
它会说:
Unpacking C:\Python34\Scripts\pygame-1.9.2a0-cp34-none-win32.whl
Installing collected packages: pygame
Successfully installed pygame
Cleaning up...
And it will then just say C:\Python34\Scripts>, which means that pygame has now been installed!
然后它只会说 C:\Python34\Scripts>,这意味着现在已经安装了 pygame!
Step 7
第 7 步
Go to the Python 3.4.2 Shell, and type in:
转到 Python 3.4.2 Shell,然后输入:
import pygame
- if there is an error, pygame didn't install properly, otherwise, congratulations! You can then:
- 如果有错误,pygame没有正确安装,否则,恭喜!然后你可以:
import pygame.examples.aliens as game
- and then on the next line type in:
- 然后在下一行输入:
game.main()
- to see a professional pygame example.
- 查看专业的 pygame 示例。
For more information, visit my website at: http://pygameinstall.neocities.org/
有关更多信息,请访问我的网站:http: //pygameinstall.neocities.org/
Good Luck! :)
祝你好运!:)