Python Forum
Cannot install and use pygame zero
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot install and use pygame zero
#1
I am having serious problems with pygame and pygame zero:

  1. pgzrun doesn't work ("bash: pgzrun: command not found)
    [x]I cannot install pgzero using pip (sudo: pip: command not found). But SOMETHING happens using pip3 (sudo pip3 install pgzero) -- see output below
    [x]Mu Editor CAN run pgzero programs (using the pygame zero 'mode') -- so did IT install an instance of pgzero for its exclusive use??

Output:
[b]The directory '/home/garth/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/home/garth/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting pgzero[/b] Downloading https://files.pythonhosted.org/packages/2c/66/bc46c203802d47fa30a6caa92d13392274bcbebbb9ffcd0c5ed8030b3611/pgzero-1.2.1-py3-none-any.whl (71kB) 100% |████████████████████████████████| 71kB 1.1MB/s Collecting numpy (from pgzero) Downloading https://files.pythonhosted.org/packages/45/b2/6c7545bb7a38754d63048c7696804a0d947328125d81bf12beaa692c3ae3/numpy-1.19.5-cp36-cp36m-manylinux1_x86_64.whl (13.4MB) 100% |████████████████████████████████| 13.4MB 52kB/s Collecting pygame~=2.0 (from pgzero) Downloading https://files.pythonhosted.org/packages/72/49/bd2fcbadb6a55bb24284bad4f530189401c99ffc234d51ba54756a776eb2/pygame-2.6.0.tar.gz (15.8MB) 100% |████████████████████████████████| 15.8MB 44kB/s Complete output from command python setup.py egg_info: Skipping Cython compilation WARNING, No "Setup" File Exists, Running "buildconfig/config.py" Using UNIX configuration... /bin/sh: 1: sdl2-config: not found /bin/sh: 1: sdl2-config: not found /bin/sh: 1: sdl2-config: not found /bin/sh: 1: pkg-config: not found /bin/sh: 1: pkg-config: not found /bin/sh: 1: pkg-config: not found /bin/sh: 1: freetype-config: not found /bin/sh: 1: freetype-config: not found /bin/sh: 1: freetype-config: not found Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-o5t45c01/pygame/setup.py", line 426, in <module> buildconfig.config.main(AUTO_CONFIG) File "/tmp/pip-build-o5t45c01/pygame/buildconfig/config.py", line 234, in main deps = CFG.main(**kwds, auto_config=auto) File "/tmp/pip-build-o5t45c01/pygame/buildconfig/config_unix.py", line 245, in main raise RuntimeError('Unable to run "sdl-config". Please make sure a development version of SDL is installed.') RuntimeError: Unable to run "sdl-config". Please make sure a development version of SDL is installed. Hunting dependencies... WARNING: "sdl2-config" failed! WARNING: "pkg-config freetype2" failed! WARNING: "freetype-config" failed! --- For help with compilation see: https://www.pygame.org/wiki/CompileUbuntu To contribute to pygame development see: https://www.pygame.org/contribute.html --- ---------------------------------------- [b]Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-o5t45c01/pygame/[/b]
The bold parts are in orange and red (respectively) in my terminal, so they must be 'important'.

Any suggestions? I was careful installing everything (I even keep a log) but it seems there are multiple instances of python, and the pgzero (and pygame) 'installations' are not matching up! Any help??
Reply
#2
Make sure you are using the correct versions.
It's generally I good idea to use virtual environments when installing packages.
Example

Create a directory called test
cd test
python3 -m venv venv
source venv/bin/activate
pip install pygame

Then create your pygame script and execute
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts


Reply
#3
(Sep-18-2024, 04:42 AM)menator01 Wrote: Make sure you are using the correct versions.

Thank you for your quick reply. However, I am still getting the EXACT same error as above (after following your steps).

My problems:
1) pgzero IS installed, since it WORKS with Mu Editor (unless Mu installs its own 'local' version -- which doesn't make sense)
2) ....BUT, I cannot use/see pgzrun from CL
3) I am unable to install pgzero (if I wanted to) using PIP (that is the error I get above, even in virtual environment)
4) when not in the virtual environment, I cannot even USE pip! ("command not found"), but it DOES work!
5) pygame itself is not quite right: Mu Editor is using pygame 1.9.4 (Python3), but Geany (with Python2) is using 2.0.3, and 2.6.0 (with Python3) in Thonny -- does this make sense? Does this matter for pgzero??

I'm really stuck here
Reply
#4
try sudo python3 -m ensurepip
Reply
#5
Thanks! I didn't try your suggestions since I think I found a 'fix' (after several days working on it). I wish I had tried your suggestion BEFORE 'fixing' it, so we could troubleshoot what was wrong.

(even though I had multiple problems: pgzrun not working, pygame doesn’t work with both python and python3, pip not working – cannot install modules, …)

Here was my ‘fix’ (but I’m not experienced enough to know WHICH fixed WHAT!)

update/install ‘missing’ python packages (python-pygame, python-pygame-sdl2, python-sdl2, python3-sdl2)
upgraded pip and setup_tools, then reinstalled python package (pgzero) through PIP
(something else, but I forgot?)

Anyway, ‘all’ of my python/IDE/pygame/pgzero problems seem to be fixed! I just wish I knew what was wrong (and why the above ‘fixes’ worked), especially since there was so many (seemingly independent) problems!

Thanks for replying with help.
Reply
#6
(Sep-21-2024, 06:57 AM)Larz60+ Wrote: try sudo python3 -m ensurepip

FYI, that didn't work (even though I did my 'fixes' and everything seems to be working now!) This is really weird.

Output:
ensurepip is disabled in Debian/Ubuntu for the system python. Python modules for the system python are usually handled by dpkg and apt-get. apt-get install python-<module name> Install the python-pip package to use pip itself. Using pip together with the system python might have unexpected results for any system installed module, so use it on your own risk, or make sure to only use it in virtual environments.
What does that tell you?
Reply
#7
These packages are written by the community ( you can find author, and usually am e-mail address on PyPi.org.
It's best to contact the author with any issues.
garthE likes this post
Reply
#8
(Sep-21-2024, 08:50 PM)Larz60+ Wrote: These packages are written by the community ( you can find author, and usually am e-mail address on PyPi.org.
It's best to contact the author with any issues.

Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to install pygame (but it seems to already be installed) garthE 1 1,532 Apr-15-2025, 05:02 PM
Last Post: jassonadder
  Can't get pygame to install djwilson0495 13 15,308 Dec-07-2020, 01:30 PM
Last Post: djwilson0495
  Trying to install pygame Mac OS x high sierra giladal 2 3,672 Oct-18-2020, 09:27 PM
Last Post: nilamo
  Error to install pygame skp 1 4,258 Apr-14-2020, 05:17 PM
Last Post: joe_momma
  PIP cannot install Pygame Amaly84 6 13,558 Sep-04-2019, 07:59 PM
Last Post: Amaly84
  pip install pygame choking on SDL dependency sneakyimp 20 17,135 Jan-23-2019, 12:36 PM
Last Post: metulburr
  pip can't install pygame SheeppOSU 1 10,326 Dec-08-2018, 08:20 PM
Last Post: snippsat
  How to install Pygame chappie 2 4,236 Dec-06-2017, 10:47 PM
Last Post: chappie
  How to begin coding for game making [Install pygame on mac] mattkrebs 2 6,128 Apr-02-2017, 10:57 AM
Last Post: machrider
  [split] permission error on pygame install pyteach 7 9,891 Jan-23-2017, 11:00 PM
Last Post: pyteach

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020