Search code examples
pythonpython-2.7portable-applications

How can you see what import fails in an imported module?


I need to make a portable app to put on a device and I want to put only the modules needed so there will not be all the standard modules so I need to see what my app needs, but if that module misses some imports I cannot see that, because it gives an error without being explicit what fails in that module:

Traceback (most recent call last):
  File "./packaging.py", line 30, in <module>
    import simplejson
ImportError: No module named simplejson

Is there a way to see what import exactly fails in that module?


Solution

  • It could be that the string /usr/lib/python2.7/dist-packages is not in your sys.path folder list so it's not being searched when attempts are made to import modules or packages.