How to set Python USER_SITE; Do I need to?

I have a Python installation on OS X (10.10; supported simply by pip) with my site packages in

/Library/Python/2.7/site-packages 

Apple's packages

 /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python 

and standard Apple Python installation in

 /System/Library/Frameworks/Python.framework/Versions/2.7 

I have not done anything special to set this up, so I assume it is pretty standard. I install my packages in the site package directory, and the only thing I did to “configure” was to trim Apple packages that I don’t need, or duplicate them in the package directory of my site.

Everything works fine, and all my paths are what I expected; however i get a confusing result when i

 python -m site 

So far this shows sys.path , which makes sense to me

 sys.path = [ '/Users/Rax', '/Users/Rax/Documents/Projects/Coding/Python', # From PYTHONPATH '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Python/2.7/site-packages', ] 

I also get

 USER_BASE: '/Users/Rax/Library/Python/2.7' (doesn't exist) USER_SITE: '/Users/Rax/Library/Python/2.7/lib/python/site-packages' (doesn't exist) ENABLE_USER_SITE: True 

which does not make sense to me.

Shouldn't USER_SITE be /Library/Python/2.7/site-packages ? If so, how can I install it (I cannot install USER_SITE in /Library/Python/2.7/ because lib/python/ added to the path)?


This doubly confuses me, because /Library/Python/2.7/site-packages correctly added to my sys.path (I don’t know how) and because

 import pkg_resources pkg_resources.__file__ 

gives /Library/Python/2.7/site-packages/pkg_resources.pyc .

+1
source share
1 answer

A user site is a mechanism that means "allow users to install Python packages locally in their home directory." (see here ). that is, it is intended for local user packages, and not for installation at the entire site level. If you have multiple users on your system, their user site packages will be separate.

The documentation shows that USER_SITE:

The path to custom package sites to run Python. May be None if getusersitepackages () has not yet been called. Default value: ~ / .local / lib / pythonX.Y / site packages for UNIX and non-structural Mac OS X builds, ~ / Library / Python / XY / lib / python / site-packages for Mac Framework build and% APPDATA% \ Python \ PythonXY \ site-packages on Windows. This directory is the directory of the site, which means that the .pth files in it will be processed.

(one that is in one place for the user base)

So, to answer your question - I believe that they are configured correctly. This is a different package location than normal.

You can also see in the documentation for the main module:

This file is intended to be created in custom package sites (see below), which is part of sys.path if it is not disabled by -s. Import without import is ignored.

Therefore, the fact that these paths do not exist does not matter.

Also regarding your question:

Should USER_SITE be / Library / Python / 2.7 / site-packages?

Note that the docs indicate ~ / Library / ... - that ~ is replaced with /Users/Rax/

You do not have to worry about setting USER_SITE. If the directory does not exist, it is still not added to the path.

+2
source

All Articles