Skip to content Skip to sidebar Skip to footer

How Do I Access Packages Installed By `pip --user`?

I realized I had an outdated numpy version: $ python Python 2.7.10 (default, Oct 23 2015, 18:05:06) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin Type 'help'

Solution 1:

As per the Python docs, this is installing using the "user scheme":

Files will be installed into subdirectories of site.USER_BASE (written as userbase hereafter).

You can see your USER_BASE value like this:

$ python -c "import site; print(site.USER_BASE)"
/Users/csaftoiu/Library/Python/2.7

I found that on my machine, this was on sys.path, but it came after the global install directories.

I solved it by adding this to my ~/.bash_profile:

# add user base to python pathexport PYTHONPATH=$(python -c "import site, os; print(os.path.join(site.USER_BASE, 'lib', 'python', 'site-packages'))"):$PYTHONPATH

Now the latest version is indeed loaded:

$ python
Python 2.7.10 (default, Oct 232015, 18:05:06)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type"help", "copyright", "credits"or"license"for more information.
>>> import numpy
>>> numpy
<module 'numpy'from'/Users/csaftoiu/Library/Python/2.7/lib/python/site-packages/numpy/__init__.pyc'>
>>> numpy.version.full_version
'1.11.1'
>>>

Solution 2:

@Claudiu's solutions works pretty well, a little bit more cleaner would be:

python3 -m site --user-base

e.g. something like this in your ~/.profile:

PATH="$(python3 -m site --user-base)/bin:${PATH}"

Solution 3:

I installed packages with sudo pip install --user option and I had to do sudo python to get it working.

vishnu$ echo$PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

With sudo:

vishnu$ sudo python
Python 2.7.10 (default, Jul 152017, 17:16:57) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type"help", "copyright", "credits"or"license"for more information.
>>> import rasa_core
>>> 

Without sudo:

vishnu$ python
Python 2.7.10 (default, Jul 152017, 17:16:57) 
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.31)] on darwin
Type "help", "copyright", "credits"or"license"for more information.
>>> import rasa_core
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named rasa_core

PS: I am running these on Mac OS High Sierra and my issue was with rasa_core and dependent packages.

Post a Comment for "How Do I Access Packages Installed By `pip --user`?"