Ask coding questions

← Back to all posts
Import Pygame not working
KrishnanShankar (2)

when I try to:

import pygame says Package Operation failed. This is the error message I get. Please help. Updating package configuration

--> /usr/local/bin/python3 -m poetry init --no-interaction

This command will guide you through creating your pyproject.toml config.

--> /usr/local/bin/python3 -m poetry add pygame
Using version ^1.9 for pygame

Updating dependencies
Resolving dependencies...

Writing lock file

Package operations: 1 install, 0 updates, 0 removals

  - Installing pygame (1.9.6)
Command ['/home/runner/.local/share/virtualenvs/python3/bin/python', '-m', '        
pip', 'install', '--no-deps', 'pygame==1.9.6'] errored with the following ou  
Collecting pygame==1.9.6                                                      
24842090fe5555b3805c050dfaa81c8094d6441db2be/pygame-1.9.6.tar.gz (3.2MB)      
    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-z3jmvg_                
f/pygame/'"'"'; __file__='"'"'/tmp/pip-install-z3jmvg_f/pygame/setup  
.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);  
eplace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__,   
'"'"'exec'"'"'))' egg_info --egg-base pip-egg-info                            
         cwd: /tmp/pip-install-z3jmvg_f/pygame/                               
    Complete output (12 lines):                                               
    WARNING, No "Setup" File Exists, Running "buildconfig/"          
    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.                                                               
ERROR: Command errored out with exit status 1: python egg_info Chec  
k the logs for full command output.                                           
WARNING: You are using pip version 19.2.3, however version 20.0.2 is availab  
You should consider upgrading via the 'pip install --upgrade pip' command.    
add [-D|--dev] [--git GIT] [--path PATH] [-E|--extras EXTRAS] [--optional] [--python PYTHON] [--platform PLATFORM] [--allow-prereleases] [--dry-run] [--] <name> (<name>)...

exit status 1 Package operation failed.
MrEconomical (2287)

you need to use a pygame repl not a python repl if you want to use pygame: