ustroetz
ustroetz

Reputation: 6312

Python is using different site packages than pip installed

The site packages pip installs are located in:

$ python -m site --user-site
/Users/ustroetz/Library/Python/2.7/lib/python/site-packages

The site packages Python is using are here:

>>> import site
>>> site.getsitepackages()
['/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/Library/Python/2.7/site-packages']

Where is the ideal place to put the site-packages if I don't use a virtual environment?

How do I change the location of either which site packages python uses or where pip installs them by default?


Also I am confused about the correct location of Python

$ which python
/usr/bin/python

>>> import sys
>>> sys.prefix
'/System/Library/Frameworks/Python.framework/Versions/2.7'

I am on Mac OS X 10.9

Upvotes: 1

Views: 1006

Answers (2)

bogatron
bogatron

Reputation: 19159

You can define the location of your user site directory with the PYTHONUSERBASE environment variable. The location you indicated in your question is the default for a Mac (see here).

If you are not using a virtual environment, I recommend putting the packages somewhere under your user directory to avoid breaking anything at the system level (or having user-code break due to system-level changes).

With regard to the location of Python, try typing

ls -lAF /usr/bin/python

and you should find that it is actually a symbolic link that points to an executable under your sys.prefix directory.

Upvotes: 1

user1364603
user1364603

Reputation:

In macosx It should be: /Library/Frameworks/Python.framework/Versions/2.7

which includes the Python executable and libraries

Upvotes: 1

Related Questions