Forum › Forums › New users › New Users and General Questions › [SOLVED] Python modules directories are messed up
Tagged: python modules dist-packages pip
- This topic has 3 replies, 2 voices, and was last updated Feb 17-6:44 am by sybok.
-
AuthorPosts
-
February 16, 2022 at 4:53 pm #77546Member
TheBigBadBoy
So here is the story :
All dist-packages were up to date (sudo apt update && sudo apt dist-upgrade).Then using “pip installed -o” showed many out-dated python modules (I only have python3). I did upgrade them (“pip install -U numpy” for example), and after everythings worked like I wanted. (I just had a warning saying that my pip installation was not in $PATH, but I did not pay attention since my system is a fresh one, I did not already touch pip or $PATH before.)
I rebooted my computer, and the updated python modules just disappeared… It’s like no upgrades were made (of python modules). Repeating the process did not change anything.
The upgrades were installed at ~/.local/lib/python3.9/site-packages, while the dist-package is at /usr/lib/python3/dist-packages, so perhaps this is why upgrades were forgotten.
I really wanted to upgrade python modules, so I did “sudo pip install -U pip”. After that, all upgraded modules were still up to date after reboot, so I thought that all the problems were gone…
The problem now :
Some antiX apps need modules from /usr/lib/python3/dist-packages (for example “app-select” needs “xdg.DesktopEntry”), but the upgraded modules in ~/.local/lib/python3.9/site-packages do not contain all needed files (for example xdg directory/module have no more the file “DesktopEntry” – I still can import xdg alone, but useless).How can I solve the problem ? Perhaps using pip in /usr/lib/python3/dist-packages instead of ~/.local/lib/python3.9/site-packages (but then, how to upgrade correctly modules) ?
- This topic was modified 1 year, 2 months ago by TheBigBadBoy.
February 16, 2022 at 6:38 pm #77552Member
sybok
::I recently installed a fresh antiX-21 (after a failed experiment, installing a package that later broke my system) and I was surprised that there are Python modules installed using ‘pip’.
However, they are not located in ‘~/.local/lib/python3/dist-packages/’ (I have no such folder there).
Perhaps, the non-root call of ‘pip install -U <package/library name>’ installed them to that local folder which takes precedence over the ‘/usr/lib/python3/dist-packages’ when Python searches the path where the binaries can be located.Therefore I suggest to do the following:
Boot the live medium used to install and explore if the folder ‘~/.local/lib/python3/dist-packages/’ is presnet there.
If not, simply move it [in your installation] to some other folder in home, e.g. to /home/<username>/dot_local_lib_py4_dist_pkgs/ and log-out.
If it does not solve the issue, you can simply move it back to its original place.February 16, 2022 at 9:18 pm #77563MemberTheBigBadBoy
::Thanks !
Removing the folders ~/.local/bin and ~/.local/list-packages works perfectly : the python modules now load the ones in /usr/lib/python/dist-packages.
I’ll dig in more on how to update the modules in /usr/lib/python3/dist-packages, by for example reading this https://stackoverflow.com/questions/24420125/python-change-user-site-directory-or-install-setup-py-prefix-with-user
Thanks again for your help, and sorry because I realize only now that this question has absolutely nothing to do with antiX.
February 17, 2022 at 6:44 am #77589Member
sybok
::Glad it worked. Please mark as solved by editing the 1st post -> prepend ‘[SOLVED]’ to the title.
-
AuthorPosts
- You must be logged in to reply to this topic.