Python 3.5.0 ::: Install pygame

Asked

Viewed 10,640 times

3

I tried to install pygame in python IDLE using Pip but it didn’t work, however I found a download that installed me a folder with pygame ready to install on my local drive. When I installed pygame and opened python I did: import pygame, but when running the module says that there is no 'pygame' module'.

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

Do you know how to install it? How do I solve this problem?

I use python 3.5.0 and Windows 10 pro

  • what operating system you use?

  • Windows 10 pro.

  • 1

    why Pip didn’t work. sorry, I don’t know how to help you, I would know if you use linux.

  • It is recommended to try in a virtual machine the same! because windows 10 still has very little resources, since it was released in September.

  • The solution is at this link: https://www.youtube.com/watch?v=ki_5uS4bOgQ :-)

3 answers

5

Note: I wrote this reply here in Stack Overflow, but I couldn’t send the links in the message (the site says I don’t have "reputation" to indicate more than 2 links per message). Therefore, I left this same message in TXT format, with the necessary links, at the following address:

https://drive.google.com/file/d/0B88rg0vKkrOFdmdKMmx0TEk5SHc/view?usp=sharing


Hello!

I have 64-bit Windows 10, and I managed to make Python and Pygame work, as follows:

1) I logged into the Python website (see TXT from the link above), and downloaded Python 3.5.1 (07/12/2015), and installed.

If I am not mistaken, during the installation I clicked on the custom installation option, and selected the option of "for all users", change environment variables, and left the default folder, which in my case was "C: Program Files Python35". If you do not enter the custom installation, I think you will later have to add the path (folders) of Python manually, in the environment variable "PATH" of Windows.

Just stating: At command prompt (CMD), when typing the PATH command, I noticed that the installer added the following folders, right at the beginning of the path:

C: Program Files Python35 Scripts ;C: Program Files Python35\;

2) I entered the Pygame website (see TXT from the link above) and selected the Pygame version corresponding to the Python version I mentioned in item 1. The version I downloaded was this:

pygame-1.9.2a0-cp35-None-win_amd64.whl

Note: As far as I could find out, in the file name, the "cp35" means that it is version 3.5 of Pygame, and the "amd64" means that it is the 64-bit version.

3) I watched the video https://www.youtube.com/watch?v=MdGoAnFP-mU, and followed his instructions.

  • The video deals with older versions of Python 3.4.1 and Pygame, but with the newer versions I mentioned in items 1 and 2, it worked.
  • The author of the video will ask to enter certain addresses, click on certain menus, etc. However, in this part, just enter the two links to which I referred above, and will come directly to the necessary files.
  • The part you will have to follow rigorously is from when it comes to renaming the file . whl to . zip, copy files into Python folder, etc.
  • Remember to adapt the folders mentioned in the video to YOUR Python folder.
  • In my case, where the video mentions the "C: Pythonxx" folder, I used the "C: Program Files Python35" folder, which is where I installed Python (assuming, as I said, the default installer folder).

  • Another precaution is that in the written instructions on the video, reference is made to a folder called "pygame-1.9.2a0.dist-info" but, a few minutes later, the author of the video corrected to "pygame-1.9.2a0.data". I call attention to this detail because, if you decide to stop the video at the beginning of the instructions and follow them the way they are there, you will not know that, later on, the name of that folder has been corrected. So I suggest you actually run the instructions as you watch the video, without skipping or trying to anticipate anything.

4) Perhaps you prefer to install Python in some other folder of your choice (C: Python35, for example), and I SUPPOSE this should work. However, whatever programs I install, I always accept the default installer folder, just to avoid the risk of running into some annoying error, because of some installer problem.

If you are going to risk installing Python in a folder other than the "default" of the installer, and in the event that Pygame doesn’t work, I suggest that you UNINSTALL (through the Windows Control Panel) the version you installed, and try to resinstall, this time using the default folder.

5) Unfortunately, if these instructions don’t work for you, I won’t have much more to say, as I’m a beginner in Python and Pygame.

Good luck! Paul

2

It is happening that python is unable to locate the installation of that library. This may happen because, for example,:

  • the library was not installed in a directory where python is searching for libraries;
  • in the installation, the corresponding directory was not added to the system variable PATH.

I do not use Windows, so I will not be able to give instructions on how to do this, but I know that can be done for each cmd session or for the whole system.

An alternative approach is to do this directly in the execution of the script, for example:

import os
import sys

pygame_dir = 'inserir aqui o directório completo para a pasta do pygame'
sys.path.append(pygame_dir)

import pygame

1

There is a very simple path: download the python; download the proper pygame version of python installed; copies the downloaded pygame file to the Scripts folder in python installation; open the prompt in the scripts folder as administrator (shift + right mouse button); execute the command: Pip install NOME_COMPLETO_DO_ARQUIVO_COM_EXTENY and enter; ready. Good luck...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.