0

I am working on a pyqt5 project in Ubuntu16.04. To install pyqt5, I used the command sudo apt-get install python3-pyqt5. In Ubuntu16.04, python3.5 comes preinstalled so initially I designed everything with python3.5. Application was running fine.

Later I upgrade the python3.5 to python3.6 using below steps:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6

After the installation, I made sure that running python3 is invoking the python3.6 and not python3.5:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2

sudo update-alternatives --config python3

After this if I type in python3, it launches python3.6.

Then I reinstalled all the python packages I required using sudo pip3 install <name> (this time it was getting installed in python3 (python3.6). After this when I ran my application, it started giving me below error:

Traceback (most recent call last):
  File "app.py", line 12, in <module>
    from PyQt5 import QtGui, QtCore, QtWidgets, QtPrintSupport
ImportError: cannot import name 'QtGui'

With python3.5 it was working perfectly fine but with python3.6 it started showing this error. How can I resolve this issue. Thanks

S Andrew
  • 5,592
  • 27
  • 115
  • 237
  • Can help? https://stackoverflow.com/a/20752155/5532710 – Carlo Zanocco Oct 08 '20 at 10:08
  • @CarloZanocco I think the linked question is different for what I have. Thanks – S Andrew Oct 08 '20 at 10:42
  • Can you go into the python3.6 directory, find pip, and run it directly from here to install the package? Probably you has missed to change pip link? – Carlo Zanocco Oct 08 '20 at 11:30
  • @CarloZanocco Actually I didn't installed `pyqt5` using pip. I installed it using `apt-get install python3-pyqt5`. Installing it using pip was giving me errors. When I looked into those errors online, I found out that I had to install specific version which is `pip3 install pyqt5==5.14.0`. After that it worked fine – S Andrew Oct 09 '20 at 04:01

1 Answers1

2

I think the I went into this issue because I upgraded the python3 from 3.5 to 3.6 so I believe some path got messed up and it wasn't able to locate the pyqt5 properly.

I installed pyqt5 using apt-get install python3-pyqt5. So I installed it using pip:

pip3 install pyqt5==5.14.0

and it worked fine.

S Andrew
  • 5,592
  • 27
  • 115
  • 237