Python 3.5.0 :::: Install pygame

3

I have tried to install pygame in python IDLE using pip but it did not work, however I found a download that installed a folder with pygame ready to install on my local drive. When I installed pygame and opened python I did: import pygame, but when I run the module it says 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     

asked by anonymous 07.11.2015 / 12:56

3 answers

5

Note: I wrote this response here in Stack Overflow, but I could not send the links in the message (the site says I have no "reputation" to indicate more than 2 links per message). So I left this same message in TXT format, with the necessary links, at the following address:

link

Hello

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

1) I entered the Python site (see TXT of the link above), and downloaded Python 3.5.1 (from 07/12/2015), and installed.

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

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

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

2) I entered the PyGame website (see TXT of 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 can figure out, in the file name, "cp35" means it is version 3.5 of PyGame, and "amd64" means it is the 64-bit version.

3) I watched the link video and followed his instructions.

  • The video is about older versions of Python 3.4.1 and PyGame, but with the more recent versions I mentioned in items 1 and 2, it worked.
  • The video author will ask you to enter certain addresses, click on certain menus, etc. However, in this part, you simply enter the two links I mentioned above, and you will get directly to the necessary files.
  • The part you will have to strictly follow is from when it handles renaming the .whl file to .zip, copying files into the 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 was where I installed Python (assuming, as I said , the default installer folder).

    Another care to take is that in the instructions written in 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 for " pygame-1.9.2a0.data ". I draw 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 the name of that folder has been corrected later. So I suggest that you actually go through the instructions as you watch the video, without skipping or trying to anticipate anything.

4) You may prefer to install Python in some other folder of your choice (C: \ Python35, for example), and I KNOW that this should work. However, whatever programs I install, I have a habit of always accepting the installers' default folder, in order not to run the risk of encountering any annoying errors, due to some installer problem.

If you are going to risk installing Python into a folder other than the "default" installer, and in case the PyGame does not work, I suggest that you DESINSTALE (from the Windows control panel) the version you installed, and try to reinstall, this time using the default folder.

5) Unfortunately, if these instructions do not work for you, I will not have much more to say, as I'm a beginner in Python and PyGame.

Good luck! Paulo

    
14.12.2015 / 21:45
2

It's happening that python is not being able to find the installation of this library. This can happen because, for example:

  • the library has not been 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 can not give instructions on how to do this, but I know what I can do for each cmd session or for the whole system.

An alternative approach is to do this directly in script execution, 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
    
02.12.2015 / 18:07
1

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

    
02.05.2017 / 15:07