Skip to content

Instantly share code, notes, and snippets.

@nonrational
Last active August 29, 2015 14:21
Show Gist options
  • Save nonrational/153707479b8e846361d7 to your computer and use it in GitHub Desktop.
Save nonrational/153707479b8e846361d7 to your computer and use it in GitHub Desktop.
list system and pip-installed modules available to the current python context
import sys as s
for m in s.modules.values():
if hasattr(m, '__file__'):
print(m.__file__)
else:
print(m)
import pip
for p in pip.get_installed_distributions():
if hasattr(p, 'location'):
print(p.location + "/" + p.key)
else:
print(p)
# install globally
pip install -r requirements.txt
python < list_available_modules.py
# install to custom path
pip install -r requirements.txt --target .pip;
PYTHONPATH=.pip:$PYTHONPATH python < list_available_modules.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment