Can't use installed python packages after upgrade to Fedora 37

When i type ueberzug in terminal :

Traceback (most recent call last):
  File "/home/firstguardian/.local/bin/ueberzug", line 5, in <module>
    from ueberzug.__main__ import main
ModuleNotFoundError: No module named 'ueberzug'

trash-put (trash-cli) :

Traceback (most recent call last):
  File "/home/firstguardian/.local/bin/trash-put", line 4, in <module>
    from trashcli.put.main import main as main
ModuleNotFoundError: No module named 'trashcli.put.main'; 'trashcli.put' is not a package

Hi @firstguardian , welcome to the community! Please take a look at the introductory posts in the #start-here category if you haven’t already had a chance to do so.

How was this installed? I’d expect you installed these using pip on F36

The default version of Python has changed in F37. It is now Python 3.11

python --version
Python 3.11.0

Each version of Python installs it’s modules in a different location in your home directory:

  • python3.10: ~/.local/lib/python3.10/site-packages
  • python3.11: ~/.local/lib/python3.11/site-packages

So, the new default Python, python3.11, cannot find the modules since they weren’t installed with python3.11.

So, if these were installed with pip for an older python 3.10, you need to:

  • either reinstall them so that python3.11 knows where to find them (simplest)
  • modify them to run with the older python—this is not trivial because it depends on how the main script is written.

While installing Python modules, it’s best to install it in a virtual environment—the virtual environment remembers what version of Python was used to create it. So these issues won’t arise.

Same issue here, but is there a reason you’re not using it from the repositories?

2 Likes

Thank you, very helpful answer. So after I reinstall, can I delete ~/.local/lib/python3.10 ?

1 Like

Yes, no, maybe…
It all depends on you usage.

If using apps that require python 3.10 then arbitrarily removing it may be premature. If not then doing so probably would be acceptable.

You should verify with all the apps that you are using whether 3.10 is required or not.

That’s an informative answer, thanks. I was wondering about the virtual environs.

My anecdote:
I updated my 36 Workstation to 37 just the other day as per the Fedora wiki on how to do it via dnf. One of two things that ceased to work was a virtual env for a small python project I’ve been using intermittently via a shell script that ran the python script via its virtual env’s python (for the dependencies installed and python).

It replied that the dependencies weren’t installed when I tried it just after the update to 37 so I went into said venv and tried to pip install the dependencies again and it didn’t know pip. Somewhat flummoxed I merely removed the venv and recreated it, reactivated it and reinstalled the deps (with pip) and then everything worked as before.

1 Like

In general, stuff in virtual environments should continue to work because they include information about what python interpreter they were created with. Sometimes, as in this case, they were created with the default python, which was 3.10 before and is 3.11 in F37. That can create issues.

One can have older (but supported) versions of Python installed on Fedora releases—the Python SIG provides these. The difference is that one will have to run them with their explicit binaries. I have python3.7, 3.9 an 3.11 installed on my F37 here:

 lash /usr/bin/python*
4.0K lrwxrwxrwx. 1 root root    9 Oct 25 10:58 /usr/bin/python -> ./python3
4.0K lrwxrwxrwx. 1 root root   10 Oct 25 10:51 /usr/bin/python3 -> python3.11
 16K -rwxr-xr-x. 1 root root  16K Oct 25 10:52 /usr/bin/python3.11
4.0K -rwxr-xr-x. 1 root root   62 Oct 25 10:51 /usr/bin/python3.11-config
4.0K -rwxr-xr-x. 1 root root 3.5K Oct 25 10:39 /usr/bin/python3.11-x86_64-config
 16K -rwxr-xr-x. 2 root root  16K Nov 14 22:17 /usr/bin/python3.7
4.0K lrwxrwxrwx. 1 root root   17 Nov 14 22:17 /usr/bin/python3.7-config -> python3.7m-config
 16K -rwxr-xr-x. 2 root root  16K Nov 14 22:17 /usr/bin/python3.7m
4.0K -rwxr-xr-x. 1 root root  177 Nov 14 22:17 /usr/bin/python3.7m-config
4.0K -rwxr-xr-x. 1 root root 3.4K Nov 14 21:38 /usr/bin/python3.7m-x86_64-config
 16K -rwxr-xr-x. 1 root root  16K Nov  9 18:55 /usr/bin/python3.9

As you see, python3 is a link to python3.11 now, and python is a link to python3. So running anything with just python will use python3.11.

I can still create a python3.9 virtual env when required, though:

$ python3.9 -m venv .venv39

$ source .venv39/bin/activate
$ python --version
Python 3.9.15
$ deactivate 

# default system python version
$ python --version
Python 3.11.0