Unable to install with pip

When installing using pip (or pip3), I get the following error “Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-NMCKed/pgzero/” (yes, I am trying to install the pgzero module, which isn’t really supported in this forum, but the issue is not pygamezero but PIP!)

Note that pgzero MUST already be installed, but it only works within a specific IDE (Mu editor), and not from CL (using the pgzrun command, “command not found”). This is NOT a request for pygame zero help, but help with PIP!

Any suggestions??

aks the lib’s vendor.

1 Like

This isn’t a failure in pip rather a failure in the package. You need to talk to the owner/maintainer of that library.

It isn’t actually pip at fault here.

PyPI can distribute packages in 2 forms: a wheel which is a prebuilt zip
file which can just be unpacked directly into your python package area,
and a source distribution (aka an “sdist”) which is the fallback, where
the source is fetched and some kind of package specific built step is
run for the install.

The error you cite comes from the second flavour.

Quite possibly it isn’t even pgzero producing this, but some other
package on which it depends (which pip will be fetching for you to
support the pgzero package). You would need to show the entire error
output for us to figure that out.

FYI, installing pgzero here fetched entirely wheels, with no “build
from source” involved. But I might have some things already installed:

 [~]fleet2*> python3 -m pip install pgzero
 Collecting pgzero
   Downloading pgzero-1.2.1-py3-none-any.whl.metadata (2.3 kB)
 Collecting pygame~=2.0 (from pgzero)
   Downloading pygame-2.6.0-cp310-cp310-macosx_10_9_x86_64.whl.metadata (12 kB)
 Requirement already satisfied: numpy in ./var/venv/3.10.6-pyenv/lib/python3.10/site-packages (from pgzero) (1.26.2)
 Downloading pgzero-1.2.1-py3-none-any.whl (71 kB)
 Downloading pygame-2.6.0-cp310-cp310-macosx_10_9_x86_64.whl (13.1 MB)
    ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.1/13.1 MB 1.9 MB/s eta 0:00:00
 Installing collected packages: pygame, pgzero
 Successfully installed pgzero-1.2.1 pygame-2.6.0

So you’ll need to provide the entire error output if anyone is to help
you with specifics.

One thing you could try is the --prefer-binary option, eg:

 python3 -m pip install --prefer-binary pgzero

Note that the help for this says:

 --prefer-binary             Prefer binary packages over source packages,
                             even if the source packages are newer.

so you might end up with a slightly older version of the package (or
prerequisite packages). Assuming it helps.

Thanks Dan (and Frank)! I will do that (even thought I found a ‘fix’). I was hoping that someone else has seen this problem and had a fix (before I contact author/vendor)

I continued my investigation, and I seem to have found a fix. ‘Everything’ seem to be working well now! But I would like to know WHY and WHICH ONE fixed what! – I’m not experienced or knowledgeable enough to know. Here was my ‘fix’:

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! An you are right, it didn’t seem to be a problem with PIP (not part of the ‘fix’).

I just wish I knew what was wrong (and why the above ‘fixes’ worked), especially since there was so many (seemingly independent) problems!

Of course. I had posted it in a different post, and didn’t repeat it here (I was trying to reframe the problem for each specific issue). I don’t know if that output would have helped here. The only reference to PIP was:

[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.

and the CL error message ended with:

[b]Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-o5t45c01/pygame/[/b]

I haven’t tried the --prefer-binary option.

HOWEVER, everything seem to be working well now, despite the multiple problems: (pgzrun not working, pygame doesn’t work with both python and python3, pip not working – cannot install modules, …) Here was my ‘fix:

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?)

I just don’t know WHY this worked (and what it had to do with PIP). I’m not experienced or knoweldgeable enough to know WHICH fixed WHAT!

Thanks for your reply!

My guess is your IDE is setting up a dev environment for you, which sets up the path to your project dir, where Python libraries are installed. They are not installed to a central directory like Perl used to do.

But when you run the CLI version of Python you are not using a CLI environment, like virtualenv. So do these steps at the CLI level. I had this problem also when learning Python and using an IDE.

  1. I’m assuming you have a project dir called project1.
  2. At the CLI command line go inside the project1 dir.
  3. Install virtualenv with pip install virtualenv assuming your path is set up to find pip.
  4. Virtualenv could end up in C:\Users\MYUSER\AppData\Local\Programs\Python\Python311\Scripts
  5. Use virutalenv to make an environment: virtualenv .venv. .venv is our environment name. This also creates a subdir of .venv\.
  6. Start the venv by typing .venv\scripts\activate.
  7. At this point the correct paths should be set up.
  8. Now install your modules all over again in this environment.
  9. When done with this project, or you switch to a n ew project, deactivate this project env with .venv\scripts\deactivate. Now cd to the new dir and activate the new environment with .venv\scripts\activate.

EDIT: An IDE should set up your path to a Python if you use the CLI started within the IDE itself. Like VSC does. I didn’t use Pycharm that much though so I don’t now about Pycharm.

1 Like

The setuptools package is core to a lot of “build from source” flows.
It could well be that.

A source package with a compile step or other complexities (as opposed
to just being source where the author hasn’t provided a wheel) often
uses setuptools to specify the build process.

Upgrading pip is good, but pip mostly fetches packages and followed
the dependency chains. You had build errors, and pip hands off to a
tool like setuptools for that.

1 Like