How to find python package’s file location

Here is simple python code snippet to see the file location of a python package on command line:

$ python -c "import urllib2; print urllib2.__file__;"

.pyc extension represent the compiled python code. To see source file, replace .pyc with .py. So in above case /usr/lib/python2.7/ is the main file.

Share this article: share on Google+ share on facebook share on linkedin tweet this submit to reddit


Click here to write/view comments