• Register
1 vote


I am new in python programming. I trired to istall pygame and I wrote some code about it:

import sys
import settings
import pygame

def run_game():
  all_settings = settings()
  screen = pygame.display.set_mode(
      (all_settings.screen_width, all_settings.screen_length))
  pygame.display.set_caption("Alien Invaders")

  while True:

    for event in pygame.event.get():
      if event.type == pygame.QUIT:




But it shows me a huge error message like below:

   ERROR: Command errored out with exit status 1:                            
     command: /home/runner/.local/share/virtualenvs/python3/bin/python -c 'i  
mport sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-gbk6qx6                
o/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-gbk6qx6o/pygame/setup  
.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().r  
eplace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__,   
'"'"'exec'"'"'))' egg_info --egg-base pip-egg-info                            
         cwd: /tmp/pip-install-gbk6qx6o/pygame/                               
    Complete output (12 lines):                                               
    WARNING, No "Setup" File Exists, Running "buildconfig/config.py"          
    Using UNIX configuration...                                               
    /bin/sh: 1: sdl-config: not found                                         
    /bin/sh: 1: sdl-config: not found                                         
    /bin/sh: 1: sdl-config: not found                                         
    Hunting dependencies...                                                   
    WARNING: "sdl-config" failed!                                             
    Unable to run "sdl-config". Please make sure a development version of SD  
L is installed.  
ImportError: No module named 'pygame'

Can anybody help?

10 7 2
6,060 points

2 Answers

1 vote


Please follow the steps that I have mentioned below:
1. Open the folder where your python is installed
2. Open scripts folder
3. Type cmd in the address bar. It opens a command prompt window in that location
4. Type pip install pygame and press enter (it should download and install pygame module)

Now run your code and it should work. Happy coding.

11 6 4
34,950 points
0 votes


Three methods to check this:

1. Employing apt-cache to search and apt-get to install :

apt-cache search pygame


python-pygame - SDL bindings for games development in Python

Thereafter install:

sudo apt-get install python-pygame

2. Employ pip:

pip install Pygame

3. Manual installation:

  • Download the source from Pypi;

  • Extract the .tar.gz file, and install employ:

    python setup.py install

obs: check the python version you need to install, in case you use Python3, employ:

pip3 install Pygame

Go to python/scripts folder, open a command window to this path, type the following command line:

C:\python34\scripts> python -m pip install pygame --user

To examine it, open python IDE and type

import pygame

print (pygame.ver)

I was attempting to figure this out for at least an hour. And you're correct the problem is that the installation files are all for 32 bit.

Only pick the similar version according to your python version and it must perform like magic. The installation feature will fetch you to a bright-blue screen as the installation (at this point you know that the installation is appropriate for you).

Thereafter go into the Python IDLE and type "import pygame" and you must not obtain any more errors.

Here are instructions for users with the newer Python 3.5 (Google brought me here, I doubt other 3.5 users might end up here as well):

I only successfully installed Pygame 1.9.2a0-cp35 on Windows and it runs with Python 3.5.1.

  • Install Python, and keep in mind the install location

  • Go here and download pygame-1.9.2a0-cp35-none-win32.whl

  • Move the downloaded .whl file to your python35/Scripts directory

  • Open a command prompt in the Scripts directory (Shift-Right click in the directory > Open a command window here)

  • Enter the command:

    pip3 install pygame-1.9.2a0-cp35-none-win32.whl

  • In case you obtain an error in the last step, attempt:

    python -m pip install pygame-1.9.2a0-cp35-none-win32.whl

And that must do it. Tested as performing on Windows 10 64bit.

10 6 4
31,120 points

Related questions

0 votes
1 answer 684 views
Problem : While trying to import the OpenCV, using import cv2 I facing the below error: /usr/local/lib/python2.7/dist-packages/cv2/__init__.py in <module>() 12 13 # make IDE's (PyCharm) autocompletion happy ----> 14 from .cv2 import * 15 16 # wildcard import ... - I am trying to play around with the Google's new Colaboratory tool. Please let me know if someone have solution for the above issue.
asked Dec 18, 2019 alecxe 7.5k points
0 votes
1 answer 4 views
I'm installing python on my windows 10 laptop, and when I try to run it I get this. Fatal Python error: Py_Initialize: unable to load the file system codec ModuleNotFoundError: No module named 'encodings' Current thread 0x0000037c (most recent call first):
asked Oct 25 psandprop 2.4k points
0 votes
1 answer 9 views
I wanna use scikit-learn. I have typed pip install -U scikit-learn pip3 install sklearn to install it; but when i type $ Python >>> import sklearn it returns ImportError: No module named sklearn I followed other tutorials, but it doesn't work. Furthermore, my enviroment ... . What is the true code to type in the terminal? I tried to type python setup.py installin the terminal but it doesn't work
asked Oct 24 psandprop 2.4k points
0 votes
1 answer 6 views
12 I have two files. The first one has the connection and the getting of data. I import mysql.connector. This file is called tasksSql.py def get_users(): import mysql.connector con = mysql.connector.connect(user='****', password='*****', host='', ... , this isn't working! When I import the file, it gives me the error: ImportError: No module named mysql.connector What am I doing wrong?
asked Oct 24 psandprop 2.4k points
0 votes
1 answer 21 views
I am trying to pip install the MySQL-python package, but I get an ImportError. Jans-MacBook-Pro:~ jan$ /Library/Frameworks/Python.framework/Versions/3.3/bin/pip-3.3 install MySQL-python Downloading/unpacking MySQL-python Running setup.py egg_info for package ... /T/pip-build/MySQL-python Storing complete log in /Users/jan/.pip/pip.log Jans-MacBook-Pro:~ jan$ Any ideas?
asked Oct 24 psandprop 2.4k points