1

Background: I'm currently running Elementary OS Hera(Ubuntu 18.04 LTS). The distribution came with Python 3.6.9. At some point I installed Python 3.7.5...this is when the issue(s) started.

Problem: I'm attempting to install PyQt5 which keeps defaulting to the older version for some reason. I ensured that Python3 was referencing the newer version:

Wick:~$ python3 --version
Python 3.7.5

I also ensured that python3.7 was the primary version:

Wick:~$ sudo update-alternatives --config python3
There are 2 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/python3.7   2         auto mode
  1            /usr/bin/python3.6   1         manual mode
* 2            /usr/bin/python3.7   2         manual mode

BUT when I run sudo apt-get install -y python3-pyqt5 . It still continues to install to the 3.6 version. This can be verified via:

:~$ python3 -c "from PyQt5.QtCore import QSettings; print('done')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.QtCore'

AND the kicker

:~$ python3.6 -c "from PyQt5.QtCore import QSettings; print('done')"
done

OR

:~$ python3.7 -c "from PyQt5.QtCore import QSettings; print('done')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.QtCore'

Any assistance you can offer is greatly appreciated. I'm losing my mind.

p.s. apologies in advance for being a newbie

Shawn Wick
  • 11
  • 2
  • 1
    I might be misinterpreting [this page](https://packages.ubuntu.com/bionic/python3-pyqt5), but it looks like `apt-get` will *only* install this for the distribution default version 3.6. – chepner Jun 27 '20 at 14:18
  • 1
    I would recommend using a virtual environment created with /usr/bin/python3.7, then install `pyqt5` there using `pip` rather than trying to install it via your package manager. – chepner Jun 27 '20 at 14:19
  • This worked great! I'm not entirely sure how I can mark this solved based on your answer(since it's a comment) – Shawn Wick Jun 27 '20 at 15:27
  • You can write up what you did as a self-answer. – chepner Jun 27 '20 at 15:54

2 Answers2

0

The package only depends on python3.6: https://packages.ubuntu.com/bionic/python3-pyqt5. It will be installed because it is a prerequisite.

Ronie Martinez
  • 1,254
  • 1
  • 10
  • 14
0

This was resolved by @chepner:

"I would recommend using a virtual environment created with /usr/bin/python3.7, >then install pyqt5 there using pip rather than trying to install it via your >package manager."

Thanks so much!

Shawn Wick
  • 11
  • 2