Search code examples
pythonpyqt5pylintbitbucket-pipelines

Pylint import errors on Bitbucket pipeline


I am trying to setup a Bitbucket pipeline for my python project, but getting errors that do not appear on my local machine.

E0401: Unable to import 'PyQt5.QtWidgets' (import-error) E0611: No name 'QtWidgets' in module 'PyQt5' (no-name-in-module)

Locally (windows), I am able to get rid of no-name-in-module errors using --extension-pkg-whitelist=PyQt5.

image: python:3.11.4

pipelines:
  default:
    - parallel: 
      - step:
        name: Run pylint
        script:
          - pip install -r requirements.txt
          - pylint source --fail-under=9 --extension-pkg-whitelist=PyQt5

I have tried:

  • In requirements.txt: PyQt5==5.15.2 and pyqt==5.14.0
  • adding ,pyqt5,PyQt5.QtWidgets,PyQt5.QtCore,PyQt5.QtGui to the whitelist.
  • create a virtual environment, activate it and install the requirements but that did not change the end result.

Guess this is somehow related to how Qt is installed/imported in Linux since I am not able to reproduce the import-error locally?

Edit: I have also tried to install PyQt using apt-get install python3-pyqt5 since it was suggested as a fix for import error in other question. That resulted in Unable to locate package python3-pyqt5


Solution

  • The message Unable to locate package python3-pyqt5 means that the system install of pyqt5 failed, you need to find what is the name of this dependency in your system or why it's failing. Seeing that the name seems to be the right one (https://packages.debian.org/search?keywords=python3-pyqt5), you might need to do an apt update first.