6

I am unable to find a pygame download for Python 3.5 and the ones I have downloaded don't seem to work when I import to the shell. Help?

This is the message I receive on the shell:

import pygame Traceback (most recent call last): File "", line 1, in import pygame ImportError: No module named 'pygame'

Utnapishtum
  • 63
  • 1
  • 1
  • 5
  • Possible duplicate of [Installation of pygame](http://stackoverflow.com/questions/19068179/installation-of-pygame) – mech Feb 24 '16 at 18:06
  • Have you read through and followed the instructions here?: http://www.pygame.org/wiki/GettingStarted – mech Feb 24 '16 at 18:06
  • Yes I already read through the page, but it only goes up to Python 3.2 not 3.5. Is there even a download for Python 3.5? – Utnapishtum Feb 24 '16 at 18:25
  • Not as far as I know. A lot of packages update slower than Python does (heck, a lot of packages are staying in python2.7 until python3 is "finished"). – mech Feb 24 '16 at 18:47
  • You might be able to follow these instructions and make it work: http://stackoverflow.com/questions/28127730/how-to-install-pygame-on-python-3-4 – mech Feb 24 '16 at 18:47
  • There is a offical pygame installer for python version 3.4 on the bitbucket site. For python version 3.5 you have to install manually. – Fredrik Feb 24 '16 at 22:08

6 Answers6

9

I'm gonna guess your using Windows. If you are not then there is no special version of pygame for Python 3+. If you do have Windows then read below.

You will need pygame to be part of your path to do this. This is so you can use this in the command prompt. Make sure you use it as an admin when doing this.

First you need to find out what bit version of Python you have. Open your Python shell and at the top of the window it should say something like "Pygame V(some number) (bit number)" You want the bit number.

Now you ned to open the command prompt. Use the "windows key + r key" to open the run menu, and type "cmd" and press enter. Or you can just search your PC for "cmd" and right click on it and select "run as admin" to open as an admin.

Python comes with a special path command called "pip." I am not gonna get into this module too much, but in short it is used to install addition Python modules. The first thing you need to do is this command...

pip install wheel

The screen should print some stuff off while doing this. You can tell if the module installed correctly because it should print something like "wheel installed successfully." We are gonna need this later.

Now you need to get your pygame file. Go here and find the pygame section. If you have python 32 bit download you should download this "pygame-1.9.2b1-cp35-cp35m-win32.whl" or if you have 64 bit Python download "pygame-1.9.2b1-cp35-cp35m-win_amd64.whl". I am pretty sure these are the ones you need for your bit version, but I installed pygame on my Windows 10 a few months ago so they may be different now.

Once you have this downloaded go back to the command prompt. Enter this command...

pip install (filename)

Make sure it includes the .whl extension. If you get an error then specify the path to the folder the file is in (which should be the downloads folder). Once again you should see a message similar to "pygame installed successfully."

Once all this is done open your Python shell and type...

import pygame

If it works you now have pygame available for use. If not then there are a few more things you can try...

  1. Try restarting your PC. Sometimes these things don't take affect until a system restart.
  2. Try installing a different version of pygame from the website listed above. It may just be a simple issue due to bit version differences.
  3. Make sure you actually installed the pygame module from the file. It may of thrown an error that appeared to be an actual successful installation. It always pays to double-check.

Like I said before I installed pygame on my Windows 10 with Python 3.4 64 bit a few months ago in the same way I told you here so it should work, but may be outdated. Anyways I hope this helps you with your pygame installation issues and the best of luck to you!

HelloWorld101
  • 3,878
  • 2
  • 34
  • 47
4

For windows now you simply use pip as it's available directly to install as pygame.

Use the following command:

python -m pip install pygame

It should output something like this, then you can test if it's working by importing pygame.

PS C:\Windows\system32> python -m pip install pygame
Collecting pygame
  Downloading pygame-1.9.2b1-cp35-cp35m-win32.whl (4.4MB)
  100% |################################| 4.4MB 264kB/s
Installing collected packages: pygame
Successfully installed pygame-1.9.2b1
PS C:\Windows\system32> python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
# Note there is no error here...
>>> quit()
PS C:\Windows\system32>
Mothbawls
  • 120
  • 4
1

This worked preety well for me:

System: Ubuntu 16.10 x64

root@sonic-VirtualBox:~/python# cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.10
DISTRIB_CODENAME=yakkety
DISTRIB_DESCRIPTION="Ubuntu 16.10"
NAME="Ubuntu"
VERSION="16.10 (Yakkety Yak)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.10"
VERSION_ID="16.10"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="http://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=yakkety
UBUNTU_CODENAME=yakkety
root@sonic-VirtualBox:~/python# 

Python 2.7 + Pygame:

root@sonic-VirtualBox:~/python# python -V
Python 2.7.12+
# apt-get install python-pip
# pip install --upgrade pip
# pip install pygame

Python 3.5 + Pygame: (Python 3.5.2+ in my case)

root@sonic-VirtualBox:~/python# python3 -V
Python 3.5.2+

# sudo apt-get install python3-pip
# pip3 install --upgrade pip
# pip3 install pygame
sparskter
  • 11
  • 1
1

Download to pygame3.5

Then put this into your cmd

cd [location of python3.5]
python -m pip install [location of pygame]
python -m pip install --upgrade pip

Then type

import pygame
pygame.init()
C R
  • 2,182
  • 5
  • 32
  • 41
0

Even when you have windows 64 bit you need to get the win32.whl file , then follow the standard instructions

0

In an anaconda environment with python 3.5 installed, you can simply do:

pip install pygame

$pip install pygame
Collecting pygame
  Downloading pygame-1.9.3-cp35-cp35m-manylinux1_x86_64.whl (9.4MB)
    100% |***************************| 9.4MB 132kB/s 
Installing collected packages: pygame
Successfully installed pygame-1.9.3

I'm in ubuntu 14.04, this should work with newer and other linuxes.

calocedrus
  • 2,430
  • 20
  • 25