Skip to content

Instantly share code, notes, and snippets.

@aresler
Last active Jun 11, 2020
Embed
What would you like to do?
Python interpreter info
import sys
import os
import pkg_resources
from pprint import pprint
def get_pythonpath():
try:
return os.environ['PYTHONPATH'].split(os.pathsep)
except KeyError:
return None
pprint({
'PATH': os.environ['PATH'].split(os.pathsep),
'PYTHONPATH': get_pythonpath(),
'sys.path': sys.path,
'sys.executable': sys.executable,
'sys.prefix': sys.prefix,
'sys.version_info': sys.version_info,
'pkg_resources.working_set': list(pkg_resources.working_set),
})
@wstomv

This comment has been minimized.

Copy link

@wstomv wstomv commented Jun 10, 2020

Why is os.environ['PATH'].split(os.pathsep) inspected twice and associated with different keys? Shouldn't the second occurrence be os.environ['PYTHONPATH'].split(os.pathsep)? Note that PYTHONPATH is not always set (and usually not needed).

@aresler

This comment has been minimized.

Copy link
Owner Author

@aresler aresler commented Jun 10, 2020

What a silly mistake, thanks for pointing that out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment