raspberrypi / picamera2

New libcamera based python library
BSD 2-Clause "Simplified" License
889 stars 188 forks source link

[BUG] "pip3 install picamera2" installs WITH PyQt5 bindings #1152

Open neuron-whisperer opened 6 days ago

neuron-whisperer commented 6 days ago

Please only report one bug per issue!

Describe the bug

Installing picamera2 installs PyQt5, contrary to the instructions.

To Reproduce

python -m pip install picamera2 or some variant thereof.

Expected behaviour

The install instructions read as follows:

This is no longer the recommended way to install Picamera2. However, if you want to do so you can use ...

pip3 install picamera2[gui]

...which will install Picamera2 with all the GUI (Qt and OpenGL) dependencies. If you do not want these, please use ...

pip3 install picamera2

I am trying to install this package on a Raspberry Pi 5 running 64-bit Bookworm Lite without any windowed GUI. I installed Python 3.8.19 via pyenv (since I intend to run pygame), upgraded the OS and pip, and then found that picamera2 is not available. I followed the apt install instructions, which succeeded, but picamera2 was still not available in Python. So I tried following the above instructions to install picamera2 without GUI stuff, and it did this:

$ python -m pip install picamera2
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting picamera2
  Using cached https://www.piwheels.org/simple/picamera2/picamera2-0.1.1-py3-none-any.whl (42 kB)
Requirement already satisfied: numpy in ./.pyenv/versions/3.8.19/lib/python3.8/site-packages (from picamera2) (1.24.4)
Collecting PiDNG (from picamera2)
  Using cached pidng-4.0.9.tar.gz (21 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting piexif (from picamera2)
  Using cached https://www.piwheels.org/simple/piexif/piexif-1.1.3-py2.py3-none-any.whl (20 kB)
Collecting pillow (from picamera2)
  Using cached pillow-10.4.0-cp38-cp38-manylinux_2_28_aarch64.whl.metadata (9.2 kB)
Collecting pyopengl (from picamera2)
  Using cached https://www.piwheels.org/simple/pyopengl/PyOpenGL-3.1.7-py3-none-any.whl (2.4 MB)
Collecting PyQt5 (from picamera2)
  Using cached PyQt5-5.15.11.tar.gz (3.2 MB)

...which is clearly installing PyQt5 contrary to the install instructions.

Console Output, Screenshots

See above.

Hardware :

Raspberry Pi 5 8GB with Raspberry Pi Camera Module 3 connected.

Additional context

n/a

mgineer85 commented 5 days ago

Hey, I think best would be to use the venv as you were trying earlier but allow the venv access to the system packages: https://docs.python.org/3/library/venv.html#creating-virtual-environments Check out the --system-site-packages flag.

If you plan using numpy in your venv you might need to pin the last v1 numpy version. If you need numpy >2, also install simplejpeg in your venv as the system packages are quite outdated and saving images with picamera2 fails otherwise.

Maybe this could be addressed by updating the system packages in the OS in the future?