Ask coding questions

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

when I try to:

import pygame

repl.it says Package Operation failed. This is the error message I get. Please help.

Repl.it: 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)
                                                                                
[EnvCommandError]                                                
Command ['/home/runner/.local/share/virtualenvs/python3/bin/python', '-m', '        
pip', 'install', '--no-deps', 'pygame==1.9.6'] errored with the following ou  
tput:                                                                         
Collecting pygame==1.9.6                                                      
  Downloading https://files.pythonhosted.org/packages/0f/9c/78626be04e193c06  
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/setup.py'"'"'; __file__='"'"'/tmp/pip-install-z3jmvg_f/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-z3jmvg_f/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.                                                               
    ----------------------------------------                                  
ERROR: Command errored out with exit status 1: python setup.py 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  
le.                                                                           
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


Repl.it: Package operation failed.
Comments
hotnewtop
MrEconomical (2287)

you need to use a pygame repl not a python repl if you want to use pygame: https://repl.it/languages/pygame