from distutils.sysconfig import get_python_lib; print get_python_lib()
Returns: /usr/lib/python2.6/site-packages
import sys; print sys.path
Returns: ['', '/usr/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg', '/usr/lib/python2.6/site-packages/pip-0.6.3-py2.6.egg', '/usr/lib/python2.6/site-packages/TRML2PDF-1.0-py2.6.egg', '/usr/lib/python2.6/site-packages/django_threaded_multihost-1.3_3-py2.6.egg',...............
But how to list the "importable name" from the site-packages installed? E.g: (before import results) django, pip, trm2pdf....
Thanks.
pip is the one for the job, as it is a tool for installing and managing Python packages. After install you have to execute:
pip freeze
That will output the packages and version information in pips requirements format (can be used later to install those packages with one command). The format of the output is like:
querystring-parser==1.0
raven==1.4.6
requests==0.14.2
scipy==0.10.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With