Challenge Using PIP -r

Situation: Moving from 3.9.2 to 3.11.2 as a result of moving to Raspberry PI Bookworm. I create a PIP requirements file on 3.9.2

Problem: On 3.11.2 I created and activate a VENV then ran PIP -M PIP -R file.

  • I’ve had to remove a number of modules which errored out in subprocess.
  • Finally got to the end of the list (XDIS) then errored out on other ‘collections’ I don’t know where they are coming from.

Looking for advice

Collecting xdis==6.0.3
  Using cached xdis-6.0.3-py310-none-any.whl (134 kB)
Collecting lazy-object-proxy>=1.4.0
  Using cached lazy_object_proxy-1.10.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (70 kB)
Requirement already satisfied: setuptools in /home/pi/.venv/wc/lib/python3.11/site-packages (from logilab-common==1.8.1->-r pip_reqs.txt (line 48)) (66.1.1)
Collecting ptyprocess>=0.5
  Using cached https://www.piwheels.org/simple/ptyprocess/ptyprocess-0.7.0-py2.py3-none-any.whl (13 kB)
Collecting pygame<2.0,>=1.9.2
  Using cached pygame-1.9.6.tar.gz (3.2 MB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

I think you may have cut out a bit too much, but I do see that your upper limit requirement for pygame is forcing you into getting a source distribution (the .tar.gz) instead of a prebuilt compiled wheel file.

It doesn’t even look likepygame was built for aarch64 back in version 1.9.6? piwheels has builds for older raspberry pi hardware on Python 3.7 but nothing newer.

If you need to use this 2019 version of pygame and not a newer one then you likely need to install some additional build dependencies and there’s no guarantee such an old version will work on a newer version of Python. (I see a notice about needing a development version of SDL to build pygame if I try to install the same old version on Python 3.11 amongst some other missing dependencies).

The solution here is probably to update the project (and the requirements file) to use a newer version of pygame as those should have prebuilt wheels so you won’t need to compile them yourself. python -m pip install pygame should install pygame 2.6.1 without issues on a raspberry pi.

Thanks @DavidCEllis. Do you know of any source addressing overcoming issues with loading modules with -r? I’ve simply been following the guidance of using ‘freeze’ to create the requirements doc and loading with -r. No mention of understanding challenges.

I too saw the reference to a full SDL environment but am not sure where to load this from. A Google returned different sources. Do you have a pointer?

Sorry; I normally try to be more self sufficient but find a lack of online resources in this area.

The issue you’re running into here with using freeze is that you’re updating to a new version of Python, but keeping all of your dependency versions frozen in place as they were for the older Python install.

As such something in your requirements.txt is trying to install an old version of pygame in a newer version of Python. The reason this fails on pip install is because pygame has some components written in C that need to be compiled with dependencies and pre-compiled wheel files don’t exist for the newer Python so pip falls back to trying (and failing) to build from source.

However, even with the appropriate C dependencies there’s no guarantee everything will run correctly after due to changes made to Python between versions.

I think you may be better off investigating the requirements.txt file and removing some version specifiers in order to get up to date versions of dependencies that should at least install correctly. This may lead to needing to make some changes to whatever project uses this environment but it should at least let you get the packages installed.

Thanks @DavidCEllis. Good advice and I’ll try that.

To that end, any advice on where to load a SDL from as that was one common error.

While hopefully you wouldn’t need to build anything from source with updated packages. SDL is something you’d get from your linux distribution. The versions of everything you need will vary based on what you’re trying to compile.

The instructions for building pygame on ubuntu are probably a good place to start: CompileUbuntu - pygame wiki