

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I find the location of Python module sources?
For a pure python module you can find the location of the source files by looking at the module.__file__. For example,
>>> import mymodule >>> mymodule.__file__ C:/Users/Ayush/mymodule.py
Many built in modules, however,are written in C, and therefore module.__file__ points to a .so file (there is no module.__file__ on Windows), and therefore, you can't see the source. You can manually go and check the PYTHONPATH variable contents to find the directories from where these built in modules are being imported.
Running "python -v"from the command line tells you what is being imported and from where. This is useful if you want to know the location of built in modules.
- Related Questions & Answers
- How do I find the location of my Python site-packages directory?
- How do I unload (reload) a Python module?
- How do I disable log messages from the Requests Python module?
- How I can dynamically import Python module?
- How do I calculate the date six months from the current date using the datetime Python module?
- How do I find the size of a Java list?
- How do I find the largest integer less than x in Python?
- How I can install unidecode python module on Linux?
- How can I set the location of minor ticks in Matplotlib?
- How do I find the length of an array in C/C++?
- How do I find the intersection of two line segments in Matplotlib?
- Do I need to set up SAP user for every user of module?
- How do I get rid of the Python Tkinter root window?
- How do I install Python SciPy?
- How I can check a Python module version at runtime?
Advertisements