environment 

Send to Kindle
home » snippets » python » environment



Bag

# What is sys.path, user base and user site?  Is user
# site enabled?
# % python -m site
# That pretty prints sys.path, USER_BASE, USER_SITE and
# if it's enabled.


# Where is the user library location
import site
print site.USER_BASE
# Prints: /Users/chirayu/Library/Python/2.7

# Where is the user site-packages location
print site.USER_SITE
# Prints: /Users/chirayu/Library/Python/2.7/lib/python/site-packages

# OR
#
# % python -m site --user-base 
#     /Users/chirayu/Library/Python/2.7
# % python -m site --user-site 
#     /Users/chirayu/Library/Python/2.7/lib/python/site-packages


# What is the platform?
# The preferred way is sysconfig.get_platform() which
# can fallback to platform.platform() – but they do have
# different return values.
#
#   >>> sysconfig.get_platform()
#   'macosx-10.7-x86_64'
#   >>> platform.platform()
#   'Darwin-11.3.0-x86_64-i386-64bit'


# What options were used to build this python?
pprint.pprint(sysconfig.get_config_vars())