3

I have saw this,but my root's path have no access to pip.

here is my terminal output.

lxa@lxa-pc:~$
lxa@lxa-pc:~$ sudo -H pip -V
[sudo] lxa 的密码:
pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5)
lxa@lxa-pc:~$ pip - V 
pip 9.0.1 from /home/lxa/.local/lib/python3.5/site-packages (python 3.5) 
root@lxa-pc:~$ echo SPATH 
/home/lxa/bin:/home/lxa/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
lxa@lxa-pc:~$ sudo su
lxa@lxa-pc:/home/lxa# 
echo SPATH 
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
lxa@lxa-pc:/home/lxa#
2

pip 8.1.1 is the version of python-pip from the default Ubuntu 16.04 repositories. When installing a package with pip set the HOME environment variable to the home directory specified by the target user's password database entry by using the option -H.

In the question you linked to two different versions of pip were installed. To find out why pip -V returns a more up-to-date version of pip (pip 9.0.1) which is also installed, run the following commands:

sudo -H pip -V

This command returns pip 8.1.1 from /usr/lib/python2.7/dist-packages (python 2.7) in a default Ubuntu 16.04 installation. The command sudo -H pip3 -V returns pip 8.1.1 from /usr/lib/python3/dist-packages (python 3.5) in a default Ubuntu 16.04 installation.

which python3  

This command returns /usr/bin/python3 in a default Ubuntu 16.04 installation.

which pip

This command returns /usr/bin/pip in a default Ubuntu 16.04 installation. The command which pip3 returns /usr/bin/pip3 in a default Ubuntu 16.04 installation.

  • But where is the executable pip8.1.1 exits. I considered the environment variable equals to echo $path in root(as my screenshot) when I use -H.Am I right? But when I input sudo -H pip -V,it said pip 8.1.1 from /usr/lib/python3/dist-packages ,but this path is not in my root's environment variable.so I want to find where the pip8.1 exits.How the ubuntu1604 find it..Thank you! @karel – lxacoder May 22 '17 at 9:43
  • … or as a single command and nicely formatted: python3 -c 'import sys; print(*sys.path, sep="\n")' – David Foerster May 22 '17 at 12:01
  • echo $PYTHONPATH shows the Python path. If the variable has not been set it will be blank. If it is blank, please comment about the results of running this command to show the Python path: python3 -c 'import sys; print(*sys.path, sep="\n")' – karel May 22 '17 at 13:50
  • Maybe add that in order to update pip, you can execute pip install -U pip? – grooveplex May 22 '17 at 19:55

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.