I would like to get a list of Python modules, which are in my Python installation (UNIX server).
How can you get a list of Python modules installed in your computer?
sys.modules
pip
), you may look at pip.get_installed_distributions()
For the second purpose, example code:
import pip
for package in pip.get_installed_distributions():
name = package.project_name # SQLAlchemy, Django, Flask-OAuthlib
key = package.key # sqlalchemy, django, flask-oauthlib
module_name = package._get_metadata("top_level.txt") # sqlalchemy, django, flask_oauthlib
location = package.location # virtualenv lib directory etc.
version = package.version # version number