I need help to install a package using apt install in the Raspberry Pi using the Python version I installed using pyenv. I already tried using pip, but the installation fails. The specific package I tried to install is pyqt5, for more info. The code is running in a Raspberry Pi OS 12 Bookworm.
My goal is to use the most recent Python version installed with pyenv to create a virtual environment, development environment, and use --system-site-packages to transfer the package. The problem is that apt install always sees the system OS installation of Python, which is several versions behind the one we use for development.
I found a person asking the same question in GitHub 8 years ago and the answer at the time was that it is not possible. I hope things have evolved for the better since then.
I share the traceback of the error as requested by comments:
Collecting pyqt5
Using cached PyQt5-5.15.11.tar.gz (3.2 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [26 lines of output]
pyproject.toml: line 14: the legacy use of 'license' is deprecated and will be removed in SIP v7.0.0, use an SPDX license expression and 'license-files' instead
Traceback (most recent call last):
File "/home/meca-vision/Documents/VisionClean4-repository/2visionclean-env2/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/home/meca-vision/Documents/VisionClean4-repository/2visionclean-env2/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/meca-vision/Documents/VisionClean4-repository/2visionclean-env2/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
whl_basename = backend.build_wheel(metadata_directory, config_settings)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-lhigqra4/overlay/lib/python3.11/site-packages/sipbuild/api.py", line 28, in build_wheel
project = AbstractProject.bootstrap('wheel',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/pip-build-env-lhigqra4/overlay/lib/python3.11/site-packages/sipbuild/abstract_project.py", line 74, in bootstrap
project.setup(pyproject, tool, tool_description)
File "/tmp/pip-build-env-lhigqra4/overlay/lib/python3.11/site-packages/sipbuild/project.py", line 633, in setup
self.apply_user_defaults(tool)
File "/tmp/pip-install-wi408778/pyqt5_6eae56fded3d4c2eb48fdd123619bf15/project.py", line 68, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-lhigqra4/overlay/lib/python3.11/site-packages/pyqtbuild/project.py", line 51, in apply_user_defaults
super().apply_user_defaults(tool)
File "/tmp/pip-build-env-lhigqra4/overlay/lib/python3.11/site-packages/sipbuild/project.py", line 243, in apply_user_defaults
self.builder.apply_user_defaults(tool)
File "/tmp/pip-build-env-lhigqra4/overlay/lib/python3.11/site-packages/pyqtbuild/builder.py", line 49, in apply_user_defaults
raise PyProjectOptionException('qmake',
sipbuild.pyproject.PyProjectOptionException
[end of output]

aptinstalls modules specially created for default Python. These modules may not work with other Python versions. But you may try to copy it from system folder to your environment folder and maybe it will work.--system-site-packagesflag. This will allow you to create a venv that can see the system site packages. No need to involve pyenv. If you wanted to use pyenv so you can use a different python version, then this will never work. pyqt is compiled against the API of a specific python version, which changes from version to version. You will instead need to compile pyqt yourself.pyqt5in a Python virtual environment withpipfails. I believe this should work. -- This or work with the Python that is installed withapt(and still use virtual environments with--system-site-packages). -- Everything else will likely be an absurdly uphill battle that barely anyone will be able to help you with simply because probably no one else tries to do what you are trying to do.