0

Possible Duplicate:
Retrieving python module path

I am working on python,i installed web.py framework to develop small web applications and installed successfully. When i tried to import the from python interpreter as below

>>> import web
>>> 

Actually i want to know the installation path of the framework or a module where it is installed so i tried

>>> import sys
>>> import sys.path

ofcourse it is showing the path of many modules installed in sitepackages, but whether we can find the path of the module if we know the module name in python

Community
  • 1
  • 1
Shiva Krishna Bavandla
  • 25,548
  • 75
  • 193
  • 313

1 Answers1

0

You can look in sys.modules. For example:

>> import django
>> import sys
>> sys.modules['django']
<module 'django' from '/usr/local/lib/python2.7/dist-packages/django/__init__.pyc'>

Then: if you are constantly running into trouble with module paths [ and need to take control of that ], I'd suggest that you take a look at virtualenv ( http://www.virtualenv.org/en/latest/index.html ). It is the de-facto solution to the "module import hell" problem in the Python world.

Ngure Nyaga
  • 2,989
  • 1
  • 20
  • 30
  • The question marked as a possible duplicate above [ http://stackoverflow.com/questions/247770/retrieving-python-module-path ] has other approaches, some of which may be better. I like the "inspect" approach – Ngure Nyaga Oct 09 '12 at 10:07