Skip to content

Instantly share code, notes, and snippets.

@mkolod
Created September 8, 2017 22:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkolod/a509fbee7157a92626e003d9956d6ef3 to your computer and use it in GitHub Desktop.
Save mkolod/a509fbee7157a92626e003d9956d6ef3 to your computer and use it in GitHub Desktop.
# Find the location on the pythonpath from which
# the package was imported. This helps debug pythonpath
# priority-related conflicts.
def pkg_loc(module_name):
module = __import__(module_name, globals(), locals(), [], -1)
return module.__file__
@mkolod
Copy link
Author

mkolod commented Sep 8, 2017

Usage:

print(pkg_loc("numpy"))
/home/marek/anaconda2/lib/python2.7/site-packages/numpy/init.pyc

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