[Solved] ModuleNotFoundError: No module named 'xdg'

Dear all,

I’m running RPD on gentoo and thanks to @damonlynch we made it successfully install even on gentoo. So it worked well the recent month and today I get:

 $ rapid-photo-downloader
Traceback (most recent call last):
  File "/home/[xxx]/.local/bin/rapid-photo-downloader", line 5, in <module>
    from raphodo.rapid import main
  File "/home/[xxx]/.local/lib/python3.7/site-packages/raphodo/__init__.py", line 30, in <module>
    from xdg import BaseDirectory
ModuleNotFoundError: No module named 'xdg


 $ equery check pyxdg
* Checking dev-python/pyxdg-0.26-r2 ...
   66 out of 66 files passed

I donno the exact version… was it 2.9.23 or .24? Anyways I tried today to install the latest version and that also fails :frowning:

  $ python3 ~/Downloads/install\(1\).py
Detected Linux distribution Gentoo 
Bitte installieren sie die folgenden Pakete über ihren Paket-Manager, und wiederholen sie danach die Installation:
wheel

Sorry, it is German. It says, pls go thru your system installer and installe “wheel”
but wheel-0.35.1-r1 is actually installed by the repo, so should be also found

$ equery files wheel       
 * Searching for wheel ...
 * Contents of dev-python/wheel-0.35.1-r1:
/usr
/usr/bin
/usr/bin/wheel -> ../lib/python-exec/python-exec2
/usr/lib
/usr/lib/python-exec
/usr/lib/python-exec/python3.8
/usr/lib/python-exec/python3.8/wheel
/usr/lib/python3.8
/usr/lib/python3.8/site-packages
/usr/lib/python3.8/site-packages/wheel
/usr/lib/python3.8/site-packages/wheel-0.35.1-py3.8.egg-info
/usr/lib/python3.8/site-packages/wheel-0.35.1-py3.8.egg-info/PKG-INFO
/usr/lib/python3.8/site-packages/wheel-0.35.1-py3.8.egg-info/SOURCES.txt
/usr/lib/python3.8/site-packages/wheel-0.35.1-py3.8.egg-info/dependency_links.txt
/usr/lib/python3.8/site-packages/wheel-0.35.1-py3.8.egg-info/entry_points.txt
/usr/lib/python3.8/site-packages/wheel-0.35.1-py3.8.egg-info/not-zip-safe
/usr/lib/python3.8/site-packages/wheel-0.35.1-py3.8.egg-info/requires.txt
/usr/lib/python3.8/site-packages/wheel-0.35.1-py3.8.egg-info/top_level.txt
/usr/lib/python3.8/site-packages/wheel/__init__.py
/usr/lib/python3.8/site-packages/wheel/__main__.py
/usr/lib/python3.8/site-packages/wheel/__pycache__
/usr/lib/python3.8/site-packages/wheel/__pycache__/__init__.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/__init__.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/__init__.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/__main__.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/__main__.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/__main__.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/bdist_wheel.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/bdist_wheel.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/bdist_wheel.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/macosx_libfile.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/macosx_libfile.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/macosx_libfile.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/metadata.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/metadata.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/metadata.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/pkginfo.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/pkginfo.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/pkginfo.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/util.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/util.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/util.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/wheelfile.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/wheelfile.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/__pycache__/wheelfile.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/bdist_wheel.py
/usr/lib/python3.8/site-packages/wheel/cli
/usr/lib/python3.8/site-packages/wheel/cli/__init__.py
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/__init__.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/__init__.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/__init__.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/convert.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/convert.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/convert.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/pack.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/pack.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/pack.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/unpack.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/unpack.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/cli/__pycache__/unpack.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/cli/convert.py
/usr/lib/python3.8/site-packages/wheel/cli/pack.py
/usr/lib/python3.8/site-packages/wheel/cli/unpack.py
/usr/lib/python3.8/site-packages/wheel/macosx_libfile.py
/usr/lib/python3.8/site-packages/wheel/metadata.py
/usr/lib/python3.8/site-packages/wheel/pkginfo.py
/usr/lib/python3.8/site-packages/wheel/util.py
/usr/lib/python3.8/site-packages/wheel/vendored
/usr/lib/python3.8/site-packages/wheel/vendored/__init__.py
/usr/lib/python3.8/site-packages/wheel/vendored/__pycache__
/usr/lib/python3.8/site-packages/wheel/vendored/__pycache__/__init__.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/__pycache__/__init__.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/__pycache__/__init__.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/packaging
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__init__.py
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__pycache__
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__pycache__/__init__.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__pycache__/__init__.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__pycache__/__init__.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__pycache__/_typing.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__pycache__/_typing.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__pycache__/_typing.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__pycache__/tags.cpython-38.opt-1.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__pycache__/tags.cpython-38.opt-2.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/__pycache__/tags.cpython-38.pyc
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/_typing.py
/usr/lib/python3.8/site-packages/wheel/vendored/packaging/tags.py
/usr/lib/python3.8/site-packages/wheel/wheelfile.py
/usr/share
/usr/share/doc
/usr/share/doc/wheel-0.35.1-r1
/usr/share/doc/wheel-0.35.1-r1/README.rst.bz2

So now I am all lost…

I am not familiar with gentoo. Is python mapped to Python 2 or 3?

What happens when you start python3 in the terminal and run this:

import xdg

no more python2 in gentoo

 $ python3
Python 3.7.9 (default, Oct 21 2020, 23:33:35) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import xdg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'xdg'
>>> 

Seems my python is damaged somehow, not RPD :frowning: just donno why and how to fix…
(on my lenovo T450s it still works, no comparison test though)

If python modules are insalled with portage, then install the xdg python module, which is just called xdg. If you’re using pip, then pip install xdg.

O.k…
But what messed it? Up to now it did work
/shrug

Looks like something uninstalled it

Those are the xdg packages installed and they are the same than my laptop, where it still works (laptop even do not have pyxdg)

I freshly installed all xdg related packages to no avail…

“Verfügbar” = available

$ eix -I xdg
[I] dev-libs/libxdg-basedir
     Verfügbare Versionen:   1.2.0-r1 {doc static-libs}
     Installierte Versionen: 1.2.0-r1(08:11:00 21.12.2020)(-doc -static-libs)
     Startseite:             https://github.com/devnev/libxdg-basedir
     Beschreibung:           Small library to access XDG Base Directories Specification paths

[I] dev-python/pyxdg
     Verfügbare Versionen:   0.26-r2^t {test PYTHON_TARGETS="python3_6 python3_7 python3_8 python3_9"}
     Installierte Versionen: 0.26-r2^t(08:11:08 21.12.2020)(-test PYTHON_TARGETS="python3_8 -python3_6 -python3_7 -python3_9")
     Startseite:             https://freedesktop.org/wiki/Software/pyxdg https://cgit.freedesktop.org/xdg/pyxdg/
     Beschreibung:           A Python module to deal with freedesktop.org specifications

[I] kde-plasma/xdg-desktop-portal-kde
     Verfügbare Versionen:   (5) 5.19.5 ~5.20.4 **5.20.49.9999*l[1] **9999*l[1]
       {debug screencast}
     Installierte Versionen: 5.19.5(5)(08:11:47 21.12.2020)(-debug -screencast)
     Startseite:             https://kde.org/plasma-desktop
     Beschreibung:           Backend implementation for xdg-desktop-portal that is using Qt/KDE Frameworks

[I] sys-apps/xdg-desktop-portal
     Verfügbare Versionen:   1.6.0-r2 1.8.0 {doc geolocation screencast}
     Installierte Versionen: 1.8.0(08:11:33 21.12.2020)(-geolocation -screencast)
     Startseite:             https://flatpak.org/ https://github.com/flatpak/xdg-desktop-portal
     Beschreibung:           Desktop integration portal

[I] x11-misc/xdg-user-dirs
     Verfügbare Versionen:   0.17 {gtk}
     Installierte Versionen: 0.17(08:11:58 21.12.2020)(gtk)
     Startseite:             https://www.freedesktop.org/wiki/Software/xdg-user-dirs
     Beschreibung:           Tool to help manage 'well known' user directories

[I] x11-misc/xdg-user-dirs-gtk
     Verfügbare Versionen:   0.10-r1
     Installierte Versionen: 0.10-r1(08:12:08 21.12.2020)
     Startseite:             https://www.freedesktop.org/wiki/Software/xdg-user-dirs
     Beschreibung:           Integrates xdg-user-dirs into the Gnome desktop and Gtk+ applications

[I] x11-misc/xdg-utils
     Verfügbare Versionen:   1.1.3-r1^t 1.1.3_p20200220^t 1.1.3_p20200220-r1^t {dbus doc gnome}
     Installierte Versionen: 1.1.3_p20200220-r1^t(08:11:18 21.12.2020)(dbus -doc -gnome)
     Startseite:             https://www.freedesktop.org/wiki/Software/xdg-utils/
     Beschreibung:           Portland utils for cross-platform/cross-toolkit/cross-desktop interoperability

[1] "kde" /var/lib/layman/kde

Last thing to try is the MS-WIndows-Hack… reboot :smiley:
…which also didn’t help :’-( but I have to admit, we are off topic here… SIGH

…and here comes the solution.

The problem for me was the multi-slot environment.

  • RPD looked to me like wanting python 3.7
  • on my system there is (inadvertently) 3.7, 3.8 and 3.9
  • 3.7 was the active interpreter
  • still wheel got built with 3.8
  • I set 3.8 the active interpreter and now I could have freshly installed RPD and it works (on a first glance)
1 Like