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
basel117
  • 189
  • 1
  • 10
  • Possible duplicate of [Installing pip locally without root privileges](https://stackoverflow.com/q/40852267/608639), [How to install python modules without root access?](https://stackoverflow.com/q/7465445/608639), [How to install pip (python) to user without root access](https://askubuntu.com/q/363300), [Install python package without root access](https://stackoverflow.com/q/20585218/608639), etc. – jww May 13 '19 at 18:01
  • @jww those articles don't answer my question! – basel117 May 14 '19 at 14:37

1 Answers1

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.

isalgueiro
  • 1,973
  • 16
  • 20