Search code examples
python-3.xpipminiconda

why (miniconda) pip install in .local


pip install is installing packages in my user's .local directory, a behaviour that I would like to avoid. Here is my setup:

(base) MYUSER@MYMACHINE:~$ which pip
/home/MYUSER/miniconda3/bin/pip

(base) MYUSER@MYMACHINE:~$ which python
/home/MYUSER/miniconda3/bin/python

An example trying to install bottleneck:

(base) MYUSER@MYMACHINE:~$ pip install bottleneck -v
...
Installing collected packages: numpy, bottleneck


  changing mode of /home/MYUSER/.local/bin/f2py to 775
  changing mode of /home/MYUSER/.local/bin/f2py3 to 775
  changing mode of /home/MYUSER/.local/bin/f2py3.6 to 775

Successfully installed bottleneck-1.3.2 numpy-1.19.0
Cleaning up...

Although I expect bottlneck to be installed in /home/MYUSER/miniconda3/lib/python3.7/site-packages, it actually gets installed in .local instead:

(base) MYUSER@MYMACHINE:~$ ls ~/.local/lib/python3.6/site-packages/bottleneck/
benchmark                             nonreduce_axis.cpython-36m-x86_64-linux-gnu.so  _pytesttester.py                        src
__init__.py                           nonreduce.cpython-36m-x86_64-linux-gnu.so       reduce.cpython-36m-x86_64-linux-gnu.so  tests
move.cpython-36m-x86_64-linux-gnu.so  __pycache__                                     slow                                    _version.py

I hope I have provided enough information to debug this.


Solution

  • A crucial piece of information that I thought was irrelevant is that I am executing these commands in a VNC session. It was brought to my attention that the environment variables when a new terminal is launched within the VNC session are inherited from the terminal that created the VNC session.

    For more information:

    https://unix.stackexchange.com/questions/400329/gnome-terminal-inherits-some-environment-even-with-env-i-on-a-vnc-session

    In my case, the environment variables (i.e. PATH, PYTHONPATH) were messed up due to the above reason. Solved now