Nate T
Nate T

Reputation: 845

How can I install PyQt5 in python venv?

I am on Ubuntu 20.04 and have made several attempts to install using pip. For some reason, pip just errors out. I have 3 different versions of pip on my system, and when I first tried installing PyQt5 into the system's main site-packages folder, I couldn't get any of them to install it successfully. I finally got it installed using the Apt package manager, but this is obviously not an option for a virtual environment.

Below is the full trace that I get when trying to install with pip:

ERROR: Command erored out with exit status 1:
 command: /home/ntolb/CODING_PROJECTS/python_workspaces/webscraping-projects_workspaces/scr-proj_ws1/bin/python /tmp/tmpuo_qeg4k prepare_metadata_for_build_wheel /tmp/tmpo5bkbzi5
   cwd: /tmp/pip-install-9g1_3u0b/pyqt5
 complete output (36 lines):
 Querying qmake about your Qt installation...
 Traceback (most recent call last):
   File "/tmp/tmpuo_qeg4k", line 126, in prepare_metadata_for_build_wheel
     hook = backend.prepare_metadata_for_build_wheel
 AttributeError: module 'sipbuild.api' has no attribute 'prepare_metadata_for_build_wheel'

 During handling of the above exception, another exception occured:

    Traceback (most recent call last):
      File "/tmp/tmpuo_qeg4k", line 280, in <module>
        main()
      File "/tmp/tmpuo_qeg4k", line 263, in main
        json_out['return_val'] = hook(**hook_input['kwargs'])
      File "/tmp/tmpuo_qeg4k", line 130, in prepare_metadata_for_build_wheel
        return _get_wheel_metadata_from_wheel(backend, metadata_directory,
      File "/tmp/tmpuo_qeg4k", line 159, in _get_wheel_metadata_from_wheel
        whl_basename = backend.build_wheel(metadata_directory, config_settings)
      File "/tmp/pip-build-env-gbcn5_fc/overlay/lib/python3.8/site-packages/sipbuild/api.py", line 28, in build_wheel
        project = AbstractProject.bootstrap('wheel',
      File "/tmp/pip-build-env-gbcn5_fc/overlay/lib/python3.8/site-packages/sipbuild/abstract_project.py", line 74, in bootstrap
        project.setup(pyproject, tool, tool_description)
      File "/tmp/pip-build-env-gbcn5_fc/overlay/lib/python3.8/site-packages/sipbuild/project.py", line 608, in setup
        self.apply_user_defaults(tool)
      File "/tmp/pip-install-9g1_3u0b/pyqt5/project.py", line 68, in apply_user_defaults
        super().apply_user_defaults(tool)
      File "/tmp/pip-build-env-gbcn5_fc/overlay/lib/python3.8/site-packages/pyqtbuild/project.py", line 51, in apply_user_defaults
        super().apply_user_defaults(tool)
      File "/tmp/pip-build-env-gbcn5_fc/overlay/lib/python3.8/site-packages/sipbuild/project.py", line 237, in apply_user_defaults
        self.builder.apply_user_defaults(tool)
      File "/tmp/pip-build-env-gbcn5_fc/overlay/lib/python3.8/site-packages/pyqtbuild/builder.py", line 58, in apply_user_defaults
        self._get_qt_configuration()
      File "/tmp/pip-build-env-gbcn5_fc/overlay/lib/python3.8/site-packages/pyqtbuild/builder.py", line 483, in _get_qt_configuration
        for line in project.read_command_pipe([self.qmake, '-query']):
      File "/tmp/pip-build-env-gbcn5_fc/overlay/lib/python3.8/site-packages/sipbuild/project.py", line 575, in read_command_pipe
        raise UserException(
    sipbuild.exceptions.UserException
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/ntolb/CODING_PROJECTS/python_workspaces/webscraping-projects_workspaces/scr-proj_ws1/bin/python /tmp/tmpuo_qeg4k prepare_metadata_for_build_wheel /tmp/tmpo5bkbzi5 Check the logs for full command output.

As I've said, Ive tried multiple versions of pip (which leads me to believe that the problem is with the package itself.) I've also tried updating pip, to no avail.

In summary, how can I install PyQt5 into my venv in this situation.

EDIT

I messed around with the version using:

pip install pyqt5=={version}

The current version is 5.15.11. I tried 5.15.10, 9, and 8 with no success. Next, I skipped back to 5.15.5, and it worked! This gives me a usable version of PyQt5 in my virtual environment, but I would rather be using the current. I am leaving the question open in hopes that someone knows why the current is not working.

Upvotes: 0

Views: 48

Answers (1)

ekhumoro
ekhumoro

Reputation: 120738

The PyQt5 wheels >= 5.15.8 are built with glibc 2.17+, which seems to be incompatible with your now very old ubuntu system. Given this, you should be able to install PyQt5==5.15.7 or earlier. You cannot install the later versions without re-compiling the wheels from scratch (which may not even be possible unless you update your system).

Upvotes: 1

Related Questions