Python: show where a module was imported from
Published 19 May 2015 under python, software
After importing a module in python use the following to find out where it was imported from:
>>> import astroid >>> astroid.__file__ '/usr/local/lib/python2.7/dist-packages/astroid/__init__.pyc'
This is can be useful if a package has been installed in two different ways e.g. via apt-get and via pip, and therefore, has ended up in two different install locations. In this case we had a pip install to /usr/local/lib/python2.7/dist-packages where as apt-get installed to /usr/lib/python2.7/dist-packages.
Comments
blog comments powered by Disqus