How to install PyGame on Python 3.4?

2020-01-25 10:59发布

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.

9条回答
Juvenile、少年°
2楼-- · 2020-01-25 11:28

Here is a great VIDEO tutorial: http://goo.gl/PurJqk (it is on youtube)

This is what I use to install .whl modules to python (I do this in the 64 bit windows cmd):

cd "C:\Users\(YOUR USERNAME)\Desktop" 

(assuming that you have the .whl file on your desktop)

C:\Python34\Scripts\pip install filename.whl

(where filename.whl is the full name of the .whl file, with the .whl extension)

After that it will install, and you are free to use PyGame!

查看更多
手持菜刀,她持情操
3楼-- · 2020-01-25 11:28

Step 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).

Step 2

Then download and install python 3.4.2 from http://filehippo.com/download_python/58901/ .

Step 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/#pygame and copy it into C:\Python34\Scripts .

Step 5

In C:\Python34\Scripts hold the shift key and right click. Click on 'Open new command window here'.

Step 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!

Step 7

Go to the Python 3.4.2 Shell, and type in:

import pygame

- if there is an error, pygame didn't install properly, otherwise, congratulations! You can then:

import pygame.examples.aliens as game

- and then on the next line type in:

game.main()

- to see a professional pygame example.

For more information, visit my website at: http://pygameinstall.neocities.org/

Good Luck! :)

查看更多
家丑人穷心不美
4楼-- · 2020-01-25 11:28

https://bitbucket.org/pygame/pygame/downloads

"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.

查看更多
爷的心禁止访问
5楼-- · 2020-01-25 11:29

For linux if you root user then copy paste this into terminal

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.

查看更多
霸刀☆藐视天下
6楼-- · 2020-01-25 11:35

Here is a link to download pygame for different versions of Python, up to Python 3.4 in 32 bit and 64 bit.

To test if it installed properly, open your python shell and type in this code:

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.

查看更多
ら.Afraid
7楼-- · 2020-01-25 11:39

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).

查看更多
登录 后发表回答