简体   繁体   中英

Problem to install pygame on ubuntu 20.04LTS

I am on Ubuntu 20.04LTS, and I try to install pygame (for python) for a school project. But when I try this:

sudo pip3 install pygame

I received an error:

ERROR: Command errored out with exit status 1:
 command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-szdn6q_u/pygame/setup.py'"'"'; __file__='"'"'/tmp/pip-install-szdn6q_u/pygame/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-3fqnujta
     cwd: /tmp/pip-install-szdn6q_u/pygame/
Complete output (18 lines):


WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using UNIX configuration...


Hunting dependencies...
SDL     : found 1.2.15
FONT    : not found
IMAGE   : not found
MIXER   : not found
PNG     : found
JPEG    : found
SCRAP   : found
PORTMIDI: not found
PORTTIME: not found
FREETYPE: found 23.1.17
Missing dependencies
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

Can you help me, please?

Try installing it with

sudo apt install python3-pygame

instead. The error you are getting is because you are missing the Pygame dependencies, which apt should install for you.

As a general rule, it's a good idea to install Python packages through the package manager, and use pip only if they're unavailable unavailable.

Try install like this:

python3 -m pip install pygame==1.9.5rc2

I was having same problem and it worked very well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM