Pygame is a dependency for a module in pip requirement file

I’m trying to load a pip requirements file on Raspberry PI Bookworm. Get through the modules in the file then hit, what I assume, are dependencies raised by one or more modules. I’ve hit a number of problems with pygame which I’ve overcome until this one. Looking for:

  • Finding the module(s) that need pygame to see if I need them e.g. look for Import statement in my library
  • Unpack this error to fix it. Note specific version asked for. I can install the latest one no problem but that is not in the version range looked for.
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
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [18 lines of output]
      
      
      WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
      Using UNIX configuration...
      
      Missing dependencies
      
      Hunting dependencies...
      SDL     : found 1.2.15
      FONT    : not found
      IMAGE   : not found
      MIXER   : not found
      PNG     : found
      JPEG    : not found
      SCRAP   : found
      PORTMIDI: not found
      PORTTIME: not found
      FREETYPE: found 26.2.20
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
(wc) pi@wethCAM:/media/work/bw $ 

Can you paste the requirements file here, or a link to it?

Thanks @merwok but don’t spend too much time on this. I’ve made progress.

I decided to convert the REQUIREMENTS file into a BASH script with individual PIP INSTALL’s so I could see more clearly where each was failing. This approach also exposed more issues. When checking the failed modules against the IMPORT of my Python scripts I eliminated a number of modules that weren’t being used.

I’m at the point now of running each Python script to verify it works.

Present observation is that requirement file is good as long as you are staying in the same version of Python. I’m going from 3.9 to 3.11 and PIP’s not happy.

2to3==1.0
Adafruit-Blinka==8.47.0
adafruit-circuitpython-busdevice==5.2.9
adafruit-circuitpython-connectionmanager==3.1.1
adafruit-circuitpython-dht==4.0.4
adafruit-circuitpython-requests==4.1.6
adafruit-circuitpython-typing==1.11.0
Adafruit-PlatformDetect==3.73.0
Adafruit-PureIO==1.1.11
arandr
astroid==2.5.1
asttokens==2.0.4
automationhat==0.2.0
bcrypt==3.2.0
beautifulsoup4==4.9.3
binho-host-adapter==0.1.6
blinker==1.4
blinkt==0.1.2
buttonshim==0.0.2
Cap1xxx==0.1.3
certifi==2020.6.20
cffi==1.15.0
chardet==4.0.0
click==7.1.2
colorama==0.4.4
colorzero==1.1
cryptography==3.3.2
cupshelpers==1.0
dbus-python==1.2.16
distro==1.5.0
dnspython==2.0.0
docutils==0.16
drumhat==0.1.0
envirophat==1.0.0
ExplorerHAT==0.4.2
Flask==1.1.2
fourletterphat==0.1.0
geographiclib==1.52
geopy==2.2.0
gpiozero==1.6.2
html2image==2.0.4.3
html5lib==1.1
idna==2.10
ipwhois==1.2.0
isort==5.6.4
itsdangerous==1.1.0
iw-parse==0.0.2
jedi==0.18.0
Jinja2==2.11.3
kaleido==0.2.1.post1
kaleido
lazy-object-proxy
logilab-common==1.8.1
lxml==4.6.3
markdown-it-py==3.0.0
MarkupSafe==1.1.1
mccabe==0.6.1
mdurl==0.1.2
microdotphat==0.2.1
mote==0.0.4
motephat==0.0.3
mpy-cross==1.20.0
mypy==0.812
mypy-extensions==0.4.3
numpy==1.25.0
oauthlib==3.1.0
olefile==0.46
opencv-python==4.11.0.86
packaging==23.1
paho-mqtt==1.6.1
pandas==2.0.2
pantilthat==0.0.7
paramiko==2.10.3
parso==0.8.1
patsy==0.5.3
pause==0.3
pexpect==4.8.0
pgzero==1.2
phatbeat==0.1.1
pianohat==0.1.0
picamera==1.13
picamera2==0.3.12
pidng==4.0.9
piexif==1.1.3
piglow==1.2.5
pigpio==1.78
Pillow==8.1.2
plotly==5.15.0
plotly-express==0.4.1
psutil==5.8.0
pycairo==1.16.2
pycparser==2.21
pycups==2.0.1
pyftdi==0.55.4
pygame==1.9.6
pygments==2.19.1
PyGObject==3.38.0
pyinotify==0.9.6
PyJWT==1.7.1
pylint==2.7.2
PyNaCl==1.5.0
PyOpenGL==3.1.5
pyOpenSSL==20.0.1
PyQt5==5.15.2
PyQt5-sip==12.8.1
pyserial==3.5
pysmbc==1.0.23
pystemd Manaually loaded
python-apt==2.2.1
python-dateutil==2.8.2
python-prctl==1.7
pytz==2023.3
pyusb==1.2.1
rainbowhat==0.1.0
reportlab==3.5.59
requests==2.25.1
requests-oauthlib==1.0.0
responses==0.12.1
rich==13.9.4
roman==2.0.0
rpi-ws281x==5.0.0
RPi.GPIO==0.7.1
RTIMULib==7.2.1
SciPy==1.8.1
scrollphat==0.0.7
scrollphathd==1.2.1
Send2Trash==1.6.0b1
sense-hat==2.6.0
simplejpeg==1.6.4
simplejson==3.17.2
six==1.16.0
skywriter==0.0.7
sn3218==1.2.7
soupsieve==2.2.1
spark-parser==1.8.9
spidev==3.5
ssh-import-id==5.10
statsmodels==0.14.0
suncalc==0.1.2
suntime==1.2.5
sysv-ipc==1.1.0
tabulate==0.9.0
tenacity==8.2.2
thonny==4.0.1
toml==0.10.1
touchphat==0.0.1
twython==3.8.2
typed-ast==1.4.2
typing-extensions==4.12.2
tzdata==2023.3
unicornhathd==0.0.4
urllib3==1.26.5
v4l2-python3==0.3.2
w1thermsensor==2.0.0
webencodings==0.5.1
websocket-client==1.7.0
Werkzeug==1.0.1
wrapt==1.12.1
xdis==6.0.3

So did you find which requirement caused the import of pygame?

A few ideas to get pygame installed:

  • on raspberry pi, you could try installing python3-pygame with apt, if the version available there matches what you need (pip will see that pygame is already installed so won’t try to get it from pypi – some caveats apply if you’re using a virtualenv)
  • otherwise avoid the compilation from sdist by using this index: https://www.piwheels.org/project/pygame/

BTW, your list of requirements seems strange (for example arandr is a program I use to configure my screens but I don’t see how it would be a dependency of another program): where does it come from?

And you’re right that it can be complicated to find out why something is installed (I use pipdeptree sometimes but it only helps after installing packages), and to update versions to get latest releases or to use a newer Python version. I have been using pip-compile for years to make this easier.

Ah, I see you’re getting similar advice on another thread.

People don’t mind spending time to help but please do not open multiple threads for the same problem.

Understood but I saw the one on Pygame as specific as oppose this general question. Sorry for the confusion