2

I am trying to install pip3 on a remote Linux server to which I am not root. I have Python 2.7.15rc1 and Python 3.6.7, when I type:

ls -la ~/.local/lib/python2.7/site-packages/

it returns the packages as expected,

drwx------ 2 user user   64 May 12 16:59 .
drwx------ 2 user user   64 May  7 15:58 ..
drwxrwxr-x 2 user user 4096 May 12 16:59 numpy
drwxrwxr-x 2 user user 4096 May 12 16:59 numpy-1.16.3.dist-info
drwxrwxr-x 2 user user   64 May 12 16:56 pip
drwxrwxr-x 2 user user 4096 May 12 16:56 pip-19.1.1.dist-info

ls -la ~/.local/lib/python3.5/site-packages/

I get:ls: cannot access '/home/.local/lib/python3.5/site-packages/': No such file or directory

I tried reinstalling pip3 :

~$ wget https://bootstrap.pypa.io/get-pip.py
....(connecting to ..., saving to .... , saved)
~$ python3 get-pip.py --user
Collecting pip
...
Successfully installed pip-19.1.1
~$ echo "PATH=\$PATH:~/.local/bin" >> ~/.bashrc
~$ source ~/.bashrc
~$ pip3 install numpy --user
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
ImportError: cannot import name 'main'

ps: .... means some extra written stuff

how do I deal with this, I tried installing a virtual environment this is what I get.

~$ pip install virtualenv --user
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip import main
ImportError: cannot import name main
2

1 Answer 1

3
echo "export PATH=~/.local/bin:$PATH" >> ~/.bashrc

You want bash to use pip from ~/.local/bin, not from /usr/local/bin. So place .local before every other entry in your path.

0

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