You are not logged in.
Pages: 1
I'm trying to repair pip after breaking it by accidentally moving /usr/lib/python3.8/site-packages and running sudo python3 -m pip install --user --upgrade pip.
Currently, pip -V produces this:
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==19.2.3', 'console_scripts', 'pip')()
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
return ep.load()
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
return self.resolve()
File "/usr/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3.8/site-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/main_parser.py", line 11, in <module>
from pip._internal.commands import (
File "/usr/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "/usr/lib/python3.8/site-packages/pip/_internal/commands/completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "/usr/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 21, in <module>
from pip._internal.download import PipSession
File "/usr/lib/python3.8/site-packages/pip/_internal/download.py", line 14, in <module>
from pip._vendor import requests, urllib3
ImportError: cannot import name 'requests' from 'pip._vendor' (/usr/lib/python3.8/site-packages/pip/_vendor/__init__.py)
I have reinstalled requests and other packages like urllib3 using sudo pacman -S urllib3 requests.
After reading this, I tried
sudo rm -rf /usr/lib/python3.8/site-packages/pip /usr/lib/python3.8/site-packages/pkg_resources
sudo pacman -S python-setuptools python-pip
but pip would not recover.
I also reinstalled Python using sudo pacman -S python but that didn't help.
In a moment of desperation, I did sudo easy_install pip which I'm pretty sure got me only deeper into trouble.
It seems it's not my entire Python setup that's broken since running python brings up the REPL just fine.
Is there a way to bring Python and pip into a valid state from this?
Please let me know if I can provide anymore information to debug the issue.
Last edited by mb720 (2020-01-05 09:33:51)
Offline
What is the output of which -a python
?
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
What is the output of which -a python
?
/usr/bin/python
python -V gives Python 3.8.1
Last edited by mb720 (2020-01-04 18:55:08)
Offline
Okay, I was checking that you did not have multiple versions of Python in your path. So, what happens now when you invoke Python ?
Edit: Have you reinstalled python-pip using pacman
Last edited by ewaller (2020-01-05 02:48:22)
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
It doesn't matter how many times you install or reinstall packages using pacman. You've broken your system by *trying* to install pip without using pacman. You can recover your system by removing the erroneous files you should not have (which are corrupting your pacman-installed version of pip).
Please install the "lostfiles" package and run the provided "lostfiles" program, which should print out, at a minimum, some files in /usr/lib/python3.8/site-packages/ which are untracked by pacman. Delete anything that doesn't have a good reason to exist outside of pacman (nothing in /usr/lib/python3.8/site-packages/ should ever be installed outside of pacman).
After that, if pip still doesn't work, reinstall it, as well as any other python-* packages which "pacman -Qkk" reports as modified.
In the future, don't ever use sudo pip. If you want to install pip outside of pacman, use it *without* sudo, using the --user flag, so that the worst you can do is mess up $HOME/.local/lib/python3.8/ (in which case you can delete that whole directory and try again).
The Arch Linux developers and the creators of pip are united in this belief: do not use sudo pip to modify the pip (or anything else) installed by your distro package manager.
For extra safety, you may wish to consider using "python -m venv" to create a virtualenv for your own modules, which is entirely for your private use, and unless you use --system-site-packages, it will even install its own copy of pip rather than using the pacman version.
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Okay, I was checking that you did not have multiple versions of Python in your path. So, what happens now when you invoke Python ?
Edit: Have you reinstalled python-pip using pacman
Calling python brings up the REPL.
Yes, I've reinstalled python-pip via pacman.
Please install the "lostfiles" package and run the provided "lostfiles" program, which should print out, at a minimum, some files in /usr/lib/python3.8/site-packages/ which are untracked by pacman.
Thanks for the hint.
Running lostfiles brings up a lot of files including /usr/lib/python3.6/site-packages/ and /usr/lib/python3.7/site-packages/ but nothing from directory /usr/lib/python3.8/.
Now for the good news:
After following your suggestion of running pacman -Qkk, I started reinstalling packages that showed "altered files".
The last command that installed libraries was
sudo pacman -S python-colorama python-chardet python-cffi python-cairo
I'm not sure which of those libraries fixed the original error of
ImportError: cannot import name 'requests' from 'pip._vendor'
but now, pip -V pleasantly produces
pip 19.2.3 from /usr/lib/python3.8/site-packages/pip (python 3.8)
Before being able to install a package via pip again, in my case using
python3 -m pip install --user --upgrade pynvim
I also had to install python-ordered-set to get rid of the error ModuleNotFoundError: No module named 'ordered_set':
sudo pacman -S python-ordered-set
Thanks for helping me solve this!
In the future, don't ever use sudo pip.
You bet. :-)
I wish there was a "do you really know what you're doing?" prompt after running this, warning that it will mess up your system.
Last edited by mb720 (2020-01-28 16:23:35)
Offline
python-ordered-set is a dependency of python-setuptools, which is in turn a dependency of python-pip, so I don't know why you would be missing it.
At any rate, good to see you were able to fix your issue after my cleanup advice.
I wish there was a "do you really know what you're doing?" prompt after running this, warning that it will mess up your system.
Well, there is discussion about that here: https://github.com/pypa/pip/issues/5605
pip already stopped suggesting the use of sudo pip intall --upgrade pip, if a distro pip is discovered (see https://github.com/pypa/pip/pull/5368).
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
For the record, you quoted eschwartz twice and attributed me. It was his advice that cut through this Gordian knot.
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
Just to put this out there, I just had a similar issue where pip was complaining with
ModuleNotFoundError: No module named 'ordered_set'
When trying to install virtualenvwrapper. I'm not sure what caused it, but installing the missing package with python via
sudo pacman -S python-ordered-set
did fix the error.
Perhaps this is a recent issue in pip? This said though, I did have a dependency management issue not long ago where I couldn't upgrade using pacman due to a chicken and egg problem. I had to uninstall a few packages here and force a few upgrades there to get my system updated, so this likely could have caused the above issue too.
Offline
Pages: 1