Version discrepancy of Python libs (pip vs. pacman)

$ pacman -Qoq /usr/lib/python3.8/         
error: No package owns /usr/lib/python3.8

$ find /usr/lib/ -maxdepth 1 -name python*.*    
/usr/lib/python2.7
/usr/lib/python3.9

$ python --version
Python 3.9.1

$ python -c "import sys; print(':'.join(x for x in sys.path if x))"
/home/myself:/usr/lib/python3.8/site-packages:/usr/lib/python3.9/site-packages:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload

$ echo $PYTHONPATH
:/usr/lib/python3.8/site-packages:/usr/lib/python3.9/site-packages

$ grep PYTHONPATH ~/.bashrc    
export PYTHONPATH=$PYTHONPATH:/usr/lib/python3.9/site-packages piper

How to continue from here and completely get rid of the 3.8 above?

What’s the output of:

ls /usr/lib/python3.8/site-packages/

It’s most likely left over __pycache__ folders you can safely remove.

Where did you set that? Maybe look in ~/.profile.

There’s no python3.8 dir in /usr/lib…

$ find /usr/lib/ -maxdepth 1 -name python*.*    
/usr/lib/python2.7
/usr/lib/python3.9

$ ls /usr/lib/python3.8/site-packages/
ls: cannot access '/usr/lib/python3.8/site-packages/': No such file or directory

But there’s:

$ find ~/. | grep -E "(__pycache__$)"            
./.local/lib/python3.8/site-packages/gtts_token/__pycache__
./.local/lib/python3.8/site-packages/pyttsx3/drivers/__pycache__
./.local/lib/python3.8/site-packages/pyttsx3/__pycache__
./.local/lib/python3.8/site-packages/gtts/tokenizer/__pycache__
./.local/lib/python3.8/site-packages/gtts/tests/__pycache__
./.local/lib/python3.8/site-packages/gtts/__pycache__
./.local/lib/python3.8/site-packages/jedi/plugins/__pycache__
./.local/lib/python3.8/site-packages/jedi/common/__pycache__
./.local/lib/python3.8/site-packages/jedi/api/refactoring/__pycache__
./.local/lib/python3.8/site-packages/jedi/api/__pycache__
./.local/lib/python3.8/site-packages/jedi/inference/compiled/subprocess/__pycache__
./.local/lib/python3.8/site-packages/jedi/inference/compiled/__pycache__
./.local/lib/python3.8/site-packages/jedi/inference/gradual/__pycache__
./.local/lib/python3.8/site-packages/jedi/inference/value/__pycache__
./.local/lib/python3.8/site-packages/jedi/inference/__pycache__
./.local/lib/python3.8/site-packages/jedi/__pycache__
./.local/lib/python3.8/site-packages/pluggy/__pycache__
./.local/lib/python3.8/site-packages/glances/exports/__pycache__
./.local/lib/python3.8/site-packages/glances/amps/__pycache__
./.local/lib/python3.8/site-packages/glances/plugins/sensors/__pycache__
./.local/lib/python3.8/site-packages/glances/plugins/__pycache__
./.local/lib/python3.8/site-packages/glances/outputs/__pycache__
./.local/lib/python3.8/site-packages/glances/__pycache__
./.local/lib/python3.8/site-packages/pyls_jsonrpc/__pycache__
./.local/lib/python3.8/site-packages/parso/python/__pycache__
./.local/lib/python3.8/site-packages/parso/pgen2/__pycache__
./.local/lib/python3.8/site-packages/parso/__pycache__
./.local/lib/python3.8/site-packages/pyls/plugins/__pycache__
./.local/lib/python3.8/site-packages/pyls/config/__pycache__
./.local/lib/python3.8/site-packages/pyls/__pycache__
./.local/lib/python3.8/site-packages/click/__pycache__
./.local/lib/python3.8/site-packages/scour/__pycache__
./.local/lib/python3.8/site-packages/__pycache__
./.npm-global/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/__pycache__
./.npm-global/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__pycache__

No, .profile doesn’t have anything Python related.

$ grep python3.9 ~/.* -s
.bashrc:export PYTHONPATH=$PYTHONPATH:/usr/lib/python3.9/site-packages piper

$ grep python3.8 ~/.* -s

There are no results of mentioning “python3.8” in my config files of my home dir.

Looks like you installed a couple of things through pip. You should probably update those…

1 Like

Hm. I was not focusing on pip, since the $PYTHONPATH was referring to the /usr/lib/python3.8 dir and pip to my ~/.local/lib/python3.8. But your hint may be very helpful. It may be a pip vs pacman conflict.

$ pip install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Collecting pip
  Downloading pip-20.3.3-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 1.6 MB/s 
Installing collected packages: pip

$ paccache -d
==> no candidate packages found for pruning

$ paccache -r
==> no candidate packages found for pruning

Your hint really helped! After the pip install --upgrade pip and a restart:

$ echo $PYTHONPATH
:/usr/lib/python3.9/site-packages

$ python -c "import sys; print(':'.join(x for x in sys.path if x))"
/home/me:/usr/lib/python3.9/site-packages:/usr/lib/python39.zip:/usr/lib/python3.9:/usr/lib/python3.9/lib-dynload:/home/me/.local/lib/python3.9/site-packages

No more python3.8! :smiley:

Lesson learned, perhaps if you run into this discrepancy as well, from now on you may want to use an alias like this:

alias up='sudo pacman-mirrors -f && sudo pacman -Syyu --disable-download-timeout && pip install --upgrade pip'
1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.