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__;"
/usr/lib/python2.7/urllib2.pyc

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

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

Comments

Click here to write/view comments