0

I'm running Debian on a Beaglebone which uses ARM architecture. The distribution has python 3.5, but one of my dependencies, aioserial, requires 3.6. I built python 3.6 from source to the /opt/python-3.6 directory, and linked the bin files to /usr/local/bin. Now running python --version show 3.6. Great.

Another dependency of mine, PyQT5, does not easily allow me to install via pip, so the recommended way on ARM is to use apt: apt install python3-pyqt5 python3-pyqt5.qtquick ...... It successfully installs, but running my application shows:

ModuleNotFoundError: No module named 'PyQt5'

Clearly it's installing pyqt for the old python 3.5. How can I make it install pyqt for my custom built version?

I tried switching out the symlink in /usr/bin/python to my custom built one, but that didn't work. Can I point 3.6 to a custom library directory? Or move the libraries to my custom directory somehow? If so, where are they stored?

1 Answer 1

0

Use:

/opt/python-3.6/bin/pip3 install pyqt5

This is the way to install any Python package listed on PyPI.org. Each specific Python interpreter installation has its own independent world of packages. The pyqt5 you installed via apt is only built and installed for use with the OS distro's python3 interpreter.

For things that need to be compiled, that may require a prerequisite step: Make sure your system has all of the libraries dependencies necessary to compile that package installed. On Debian-ish systems like yours a simple way of getting what you need to be able to build something yourself is sudo apt-get build-dep python3-pyqt5 - That fetches everything required to build the python3-pyqt5 debian package. Which is highly likely to be everything you need for pip to build pyqt5 downloaded from pypi.org.

BTW, as you built your own Python for your needs (good choice!), I recommend using 3.9 rather than 3.6. Always use the latest release.

As you've put a /usr/local/bin/python symlink in place to your /opt install, I also suggest putting a /usr/local/bin/pip3 symlink in place.

Never replace any of the system package manager installed and manged things (ie: restore that /usr/bin/python path to what it once was). The OS distro depends on this being its own managed python for functionality of its own packages.

5
  • Hi @gps I think you misunderstood my problem. I installed pyqt5 via apt successfully. The problem is that my custom python build does not detect it. I know this because if I try to run my application with the system's default python version 3.5, it does detect pyqt. So somehow the dependencies for python 3.6 are not linked.
    – timetofly
    Feb 24, 2021 at 4:47
  • You haven't actually installed pyqt5 for your custom built Python. Each Python installation is its own independent world with its own local built and installed site-packages directory in the module search path.
    – gps
    Feb 24, 2021 at 4:50
  • How can I install pyqt5 via apt for my custom python build then? Certainly there is a way? I ran into too many issues trying to install pyqt via pip so I'm not quite sure what else to try.
    – timetofly
    Feb 24, 2021 at 5:07
  • While hacks exist that might "work", pyqt5 installed via apt was built and installed solely for use by your system python. Consider doing a debian upgrade to get onto a modern version of Debian. python3.5 was the default on Debian Stretch. Upgrade to Buster and everything available via apt will have Python 3.7.
    – gps
    Feb 24, 2021 at 6:08
  • hack: execute this line of code sys.path.append('/usr/lib/python3.5/dist-packages') before you import pyqt5. If this works at all, realize you'd be loading an extension module compiled for debian's Python 3.5 interpreter into your 3.6 interpreter. No guarantees. Not something anyone should ever rely on.
    – gps
    Feb 24, 2021 at 6:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .