Search code examples
pythonpyqt5python-3.6ubuntu-14.04

Getting import error with sub modules of PyQt5


I am trying to install and use PyQt5 on Ubuntu 14.04. Before this, I had been using Ubuntu 18.04 and I had no problems with the installation and use of PyQt5. Because of some technical needs of a project, I need to use 14.04 instead.

After I first launch Ubuntu this is the order that I install things:

Install Python 3.6:

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

Install QT5

sudo apt-get install build-essential
sudo apt-get install qtcreator
sudo apt-get install qt5-default

Install PyQt5

sudo apt-get install python3-pyqt5
sudo apt-get install pyqt5-dev-tools
sudo apt-get install qttools5-dev-tools

After this is completed, I run this test code to see if I get an import error:

import sys
from PyQt5 import QtCore, QtWidgets

When I run it, I get this error. It gives an error for any sub module of PyQt5. On Ubuntu 18.04, I followed the same installation steps as above for qt5 and pyqt5 and it worked perfectly. (Did not install python 3.6 because it is already installed with Ubuntu 18).

Traceback (most recent call last):
File "/home/ms/test.py", line 2, in
from PyQt5 import QtCore
ImportError: cannot import name 'QtCore'

I have also tried installing pyqt5 with pip or pip3, but I get an error.

pip3 install pyqt5

Error:

Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_ms/pyqt5
Storing debug log for failure in /home/ms/.pip/pip.log

Any help would be greatly appreciated. I have been working on trying to fix this for the past couple days with still no idea what the problem could be.


Solution

  • The following steps use to install PyQt5 in a docker with ubuntu: 14.04:

    sudo add-apt-repository ppa:deadsnakes/ppa
    sudo apt-get update
    sudo apt-get install python3.6
    sudo apt-get install curl
    curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    sudo python3.6 get-pip.py
    sudo python3.6 -m pip install --upgrade pip
    sudo python3.6 -m pip install pyqt5==5.9.2
    sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev libfontconfig1
    python3.6 -c "from PyQt5 import QtCore, QtWidgets"