backintime icon indicating copy to clipboard operation
backintime copied to clipboard

[CentOS] ModuleNotFoundError: No module named 'PyQt5'

Open zakthan opened this issue 6 years ago • 14 comments

I am using centos 7 x86_64. I have installed backintime-common using yum and backtime-pt using build from source (following the steps of the documentation) Installations did not give me any errors. My python module looks good and it seems that I have installed package PyQt5.

[root@ip-10-2-11-58 sip-4.19.3]# pip3 list Package Version


cffi 1.13.2 cryptography 2.8 dbus-python 1.2.12 jeepney 0.4.1 keyring 5.0 pip 19.3.1 pycparser 2.19 PyQt5 5.13.2 PyQt5-sip 12.7.0 PyQtWebEngine 5.13.2 SecretStorage 3.1.1 setuptools 39.2.0 six 1.13.0

Nevertheless when I try to run backintime-qt I get:

[root@ip-10-2-11-58 sip-4.19.3]# backintime-qt Traceback (most recent call last): File "/usr/share/backintime/qt/app.py", line 35, in import qttools File "/usr/share/backintime/qt/qttools.py", line 21, in from PyQt5.QtGui import (QFont, QColor, QKeySequence) ModuleNotFoundError: No module named 'PyQt5' [root@ip-10-2-11-58 sip-4.19.3]#

Any ideas?

zakthan avatar Nov 17 '19 20:11 zakthan

We also have the same issue on CentOS 8:

  • PyQt5 5.15.2
  • PyQt5-sip 12.8.1

Klakurka avatar Jan 25 '21 07:01 Klakurka

Doesn't open after successful install with same error (under Linux Mint 20.2)

b-healthwrights avatar Aug 05 '21 05:08 b-healthwrights

Same here on Debian11/KDE. I think BackInTime used to work. Maybe an upgrade (e.g. of Debian) or the switch to Wayland broke it?

The strange thing is that BackInTime (as root) still works (and that even under Wayland).

I'm currently using v1.2.1.

backintime-qt --debug returns:

Traceback (most recent call last):
  File "/usr/share/backintime/qt/app.py", line 35, in <module>
    import qttools
  File "/usr/share/backintime/qt/qttools.py", line 21, in <module>
    from PyQt5.QtGui import (QFont, QColor, QKeySequence)
ModuleNotFoundError: No module named 'PyQt5'

backintime returns:

Traceback (most recent call last):
  File "/usr/share/backintime/common/backintime.py", line 27, in <module>
    import config
  File "/usr/share/backintime/common/config.py", line 32, in <module>
    import tools
  File "/usr/share/backintime/common/tools.py", line 51, in <module>
    import dbus
ModuleNotFoundError: No module named 'dbus'

pip3 list shows that these are installed:

PyQt5                 5.14.2
PyQt5-sip             12.7.2

after pip3 uninstall pyqt5 and reinstalling it (which didn't help) it shows:

PyQt5                 5.15.6
PyQt5-Qt5             5.15.2
PyQt5-sip             12.9.0

python3-dbus.mainloop.pyqt5 python3-dbus and python3-pyqt5 are installed. (#919 seems to be related.)

What should be done, has anybody solved this so far?

Edit: don't know if I did something to solve but it works now...probably it works now because of some update or because I reinstalled it. I have it installed from the Debian stable repos.

mYnDstrEAm avatar Jan 04 '22 21:01 mYnDstrEAm

PyQt5 is "just" a binding (wrapper) between python and Qt5.

I suspect that the Qt5 framework binaries itself are not installed for some reasons.

Try to install them in your package manager (which one exactly I will try to figure out for CentOS 7 once my Virtual Machine is running...)

aryoda avatar Sep 10 '22 00:09 aryoda

There is no pyqt5 in the CentOS 7 package manager. It would only be available in pip3, but pip3 wants pyqt5 15 which is not available?? So I'm not seeing a way through with that one yet.

[gsker@localhost ~]$ pip3 install PyQt5 PyQtWebEngine
Collecting PyQt5
  Using cached https://files.pythonhosted.org/packages/36/66/19983d471c702e551a19a7225a92a7c1efadd961f6c650110ed906dd0ed7/PyQt5-5.15.6-cp36-abi3-manylinux1_x86_64.whl
Collecting PyQtWebEngine
  Downloading https://files.pythonhosted.org/packages/a1/45/667e82a0f584be10d785213b04c8ce01ae4d2f63cd23ab6307312c69be89/PyQtWebEngine-5.15.5-cp36-abi3-manylinux1_x86_64.whl (228kB)
    100% |████████████████████████████████| 235kB 5.4MB/s 
Collecting PyQt5-Qt5>=5.15.2 (from PyQt5)
  Could not find a version that satisfies the requirement PyQt5-Qt5>=5.15.2 (from PyQt5) (from versions: )
No matching distribution found for PyQt5-Qt5>=5.15.2 (from PyQt5)

A debian11 user should be using the debian package rather than pip3.

gsker:~/.ssh>aptitude show backintime-qt
Package: backintime-qt                   
Version: 1.3.2-0.1

From the referenced issue, it seems like a re-install of all the pieces cleaned it up. With that said, do NOT install both pip3 and the package.
Either do pip3 and or the package and prefer the package.

gsker avatar Sep 10 '22 02:09 gsker

(After some digging -- my thoughts: ) You won't ever be able to maintain a CentOS7 install of backintime at this point. It's not worth doing. All the other pieces are moving ahead (like qt and rsync) and it will be onerous. This should probably closed as won't fix. (just my advice)

The issue with Debian11 and Mint should be addressed with a different/new issue if they still stand and not mixed in here. Any issue with BiT version 1.2.1 should be resolved by upgrade to a current backintime version and then resolved with support there.

@aryoda

gsker avatar Sep 10 '22 02:09 gsker

We don't close here with wontfix because it is disrespectful to Issue openers. It implicates there is a bug but we don't care. But of course this isn't the case.

This Issue here is not a bug in the context of our upstream project. This bug is related to CentOS itself. So please open a bug report there and be so polite to link that CentOS bug report here in that Issue so we can monitor that.

We are also very open and helpful if the CentOS package maintainer do contact us.

So we might close this bug only because it is not a bug for us (at upstream) and because of that we are not able to fix something that is out of our responsibility and possibility.

I also wasn't able to find a package repo for CentOS.

buhtz avatar Sep 10 '22 07:09 buhtz

There is no pyqt5 in the CentOS 7 package manager. It would only be available in pip3, but pip3 wants pyqt5 15 which is not available??

I had the same problem with CentOS 7 in my VM with the exact same message from your screen shot.

PyQt5 seems to search the Qt5 framework libs which are not (compeletely) installed.

I could solve this by installing some Qt5-related packages and BiT-qt 1.3.1 is running now (incl. unit test). Unluckily I forgot to take a VM snapshot before installing the Qt5 and other packages so I now have to undo this manually to find out which packages must be at least installed for the Qt5 binaries.

aryoda avatar Sep 10 '22 09:09 aryoda

The issue with Debian11 and Mint should be addressed with a different/new issue if they still stand and not mixed in here

I agree to that, I am focusing on the CentOS 7 (and possibly related 8) problem only as originally reported

@b-healthwrights @mYnDstrEAm Would you mind opening a new separate issue for your problem incl. some info to make it reproducible (python version, OS version, echo $XDG_SESSION_Type, pip3 list...) THX :-)

Any issue with BiT version 1.2.1 should be resolved by upgrade to a current backintime version and then resolved with support there.

Yes, and the OP did install BiT-common (which is 1.20 AFAIR) from the offical package and BiT-qt manually from source code so it should suffice make this work on CentOS 7 by mentioning the required Qt5 packages here and update the README (I am working on it)...

aryoda avatar Sep 10 '22 09:09 aryoda

@zakthan I think I have the solution (sorry it took 3 years) if you still have the problem:

Test setup

  • CentOS 7 (but should also work for CentOS 8 and 9)
  • KDE Plasma Desktop [Edit: Also just tested for Gnome with success]
  • x11 (echo $XDB_SESSION_TYPE)
  • Python 3.6.x
  • package "backintime-common" was not installed (but does not harm!)
  • tested with master branch of BiT today (BiT 1.3.2)

Steps to solve the missing PyQt5 dependency

Add the EPEL (= Extra Packages for Enterprise Linux) repo to the package manager. It provides free and open source packages that are not available in the official package repository. See: https://docs.fedoraproject.org/en-US/epel/

sudo yum install epel-release
sudo yum update

Then install PyQt5 from EPEL for your python3 version, eg. for

$ python3 --version
Python 3.6.8

install

sudo yum install python36-qt5
# sudo yum install 

Note: Other required Python packages could also be installed this way if missing, eg python36-keyring.

Then check if PyQt5 is really available via

pip3 list
# Should contain two output lines like
#   PyQt5 (5.12.1)
#   PyQt5-sip (4.19.22)

Now you can build BiT like described in the README

Next steps

  1. Could somebody please verify that my instructions do really work (and report the result here)
  2. Add the instructions to the README file at Github (or elsewhere, eg. in a FAQ)

aryoda avatar Sep 10 '22 18:09 aryoda

Nice! I was close - had the EPEL but hadn't gone any further. I built a centos7 minimal install and added X windows and xfce4 to it. Adding EPEL and installing python36-qt5 and python36-keyring worked fine. Then I installed git and cloned the repo and ran ./configure --prefix=/usr; make; make install in both common/ and qt/

The only issue I had after that was one python package.

Traceback (most recent call last):
  File "/usr/share/backintime/common/backintime.py", line 27, in <module>
    import config
  File "/usr/share/backintime/common/config.py", line 32, in <module>
    import tools
  File "/usr/share/backintime/common/tools.py", line 36, in <module>
    from packaging.version import Version
ModuleNotFoundError: No module named 'packaging'

It was quickly solved with sudo yum install python36-packaging I was able to do "backintime (Root)" and make a backup.

edit: I did not follow the instructions to the letter -- going back and running make test in common/ I get this:

F..........
======================================================================
FAIL: test_set_snapshots_path_fails_on_ro (test.test_config.TestConfig)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/backintime/common/test/test_config.py", line 37, in test_set_snapshots_path_fails_on_ro
    self.assertFalse(self.cfg.setSnapshotsPath(dirpath))
AssertionError: True is not false

gsker avatar Sep 10 '22 20:09 gsker

@ gsker Thanks a lot for your input, testing and feed-back

I was close - had the EPEL but hadn't gone any further.

Yes, the EPEL package name could be better, eg. python36-PyQt5 instead of just python36-qt5. This "crippled" name is difficult to find (eg. via the find feature in the package GUI gpk-application)...

running make test in common/ I get this: FAIL: test_set_snapshots_path_fails_on_ro (test.test_config.TestConfig)

Very good eyes ;-) I have just checked this in my setup with make test after a fresh (re)boot of CentOS and the unit tests show the same failure (and some others)!

Interestingly starting the unit tests differently then produces NO unit test failure:

$ python3 -m unittest -b
.................................................................................................................................ss......................................................................s.......................s..........sssssssssssssssssssssssss...ssssss.........sssssssss.....s.......s..s......s...................s.s...ss...s.............
----------------------------------------------------------------------
Ran 356 tests in 12.092s

OK (skipped=53)
/usr/lib64/python3.6/subprocess.py:786: ResourceWarning: subprocess 6183 is still running

And this test call also succeed (except the skipped tests):

$ make test-v
...
test_set_snapshots_path_fails_on_ro (test.test_config.TestConfig) ... ok
test_set_snapshots_path_permission_fail (test.test_config.TestConfig) ... ok
...

Running the test alone does also succeed:

$ python3 -m unittest  -b test/test_config.py
...........
----------------------------------------------------------------------
Ran 11 tests in 0.026s
OK

Interestingly: Running make test again it runs without a failure...

I'd suspect a test setup or cleanup issue - a bug in the unit test ;-)

I will have a look at that the next days... but think we could close the issue if the OP agrees...

aryoda avatar Sep 10 '22 20:09 aryoda

Great work :) While you get the test failure figured out, I'll have to think about where best to publish the "Installing backintime on CentOS 7 and 8" instructions ;)

emtiu avatar Sep 10 '22 21:09 emtiu

  File "/usr/share/backintime/common/tools.py", line 36, in <module>
    from packaging.version import Version
ModuleNotFoundError: No module named 'packaging'

It was quickly solved with sudo yum install python36-packaging

I think this new package (and therefore your error since it is not installed) was introduced with this commit two days ago: https://github.com/bit-team/backintime/commit/5a62ffe1b96f74989c5e0a20a6f4a066c6a03312

Somehow the dependency management of imported packages could be improved (don't know how, it is OS-specifc), but for this case at least the README should be extended.

Edit: The dependency is documented now via the merged PR #1291 (in the README)

aryoda avatar Sep 11 '22 11:09 aryoda

Could this issue be closed now?

@emtiu Perhaps your idea of writing "Installing backintime on CentOS 7 and 8" instructions could be added as a new issue?!

aryoda avatar Oct 06 '22 18:10 aryoda

Agreed.

emtiu avatar Oct 07 '22 20:10 emtiu