Environment
Description
Here is what I get after using the above upgrade command for my user account (for example when trying "pip install spacy"):
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in
load_entry_point('pip==7.1.0', 'console_scripts', 'pip')()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 299, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2229, in load_entry_point
return ep.load()
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1953, in load
raise ImportError("%r has no %r attribute" % (entry,attr))
ImportError:
Note
This is apparently the same problem as "https://github.com/pypa/pip/issues/5817".
My guess is you did not put ~/.local/bin
in your PATH.
Like @uranusjr indicated - it looks like you have done a --user
install of pip (since the module loaded is /u/afaqeeh/.local/lib/python2.6/site-packages/pip/init.pyc
), but your shell is resolving pip
to the global /usr/bin/pip
script. These can be incompatible as mentioned in #5599. You should use the pip script from ~/.local/bin/pip
directly or by adding it to your PATH
environment variable.
Please let us know if that helps!
@uranusjr @chrahunt Many thanks for your replies. I tried adding ~/.local/bin/pip
to my PATH
by PATH=~/.local/bin/pip:$PATH
or by export PATH=~/.local/bin/pip:$PATH
and then source ~/.bash_profile
but none of them worked (I guess because for some reason the new PATH is not added to ~/.bash_profile
).
@ali-faqeeh Don鈥檛 spell out pip
in the PATH. You should only include up to the bin
part.
@uranusjr so it seems there was indeed a path problem and I think now it might have been fixed with PATH=~/.local/bin:$PATH
. At the moment it seems the local pip is working and the system pip is not. Now while a command like python3 -m pip install --user spacy
works, for commands like pip install spacy
and pip install --upgrade --user pip
I get this new error:
Traceback (most recent call last):
File "/u/afaqeeh/.local/bin/pip", line 7, in <module>
from pip._internal.main import main
File "/u/afaqeeh/.local/lib/python2.6/site-packages/pip/_internal/main.py", line 13, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/u/afaqeeh/.local/lib/python2.6/site-packages/pip/_internal/cli/autocompletion.py", line 11, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/u/afaqeeh/.local/lib/python2.6/site-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/u/afaqeeh/.local/lib/python2.6/site-packages/pip/_internal/cli/cmdoptions.py", line 105
binary_only = FormatControl(set(), {':all:'})
You have multiple pips installed. When you run python3 -m pip
it uses the pip installed to the Python 3 site-packages or user directory (you can see which by executing python3 -m pip -V
). Your stack trace indicates that the latest pip (indicated by the file pip/_internal/main.py
being in the stack, which was only in this most recent release) is also installed under Python 2.6 which has not been supported for some time. Python 2.6 does not recognize the newer syntax {':all:'}
so it is understandably confused.
If you just want to use python3
as your main Python, and you want ~/.local/bin/pip
to reference that one, then you can try python3 -m pip install --user --upgrade pip
- it should overwrite the existing ~/.local/bin/pip
which was installed with the original pip under Python 2.6. If it says something like "Requirement already satisfied", then you can also provide --ignore-installed
to force it to reinstall and generate the pip
script.
If you want to use pip with your Python 2.6, then check out the instructions here, where there is a link to a Python 2.6 compatible get-pip.py to help you get a compatible version set up. You can also find the script here if needed.
@chrahunt Brilliant! As I'm only using python 3 tried python3 -m pip install --user --upgrade pip
and now commands like pip install spacy
work very well.
I should point out though that first I should update PATH
every time I log in to the server using PATH=~/.local/bin:$PATH
(probably PATH
is set to default at each new login).
Glad it helped! You can put export PATH=~/.local/bin:$PATH
in ~/.profile
and it should get picked up automatically on login depending on which shell you're using and what other files exist in your home folder. Check out the man page for your shell for more details.
Since this seems to be resolved I will close it, but please let us know if you have any other issues!