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?

有帮助吗?

解决方案

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.

其他提示

The error means, that the import import simplejson fails because there is “[n]o module named simplejson”. The solution is to simply install said module.

you can catch the exceptions, to know what went wrong and handle them appropriately:

try:
   import simplejson
except ImportError:
   print "simplejson module not found"
   #or do something else here, may be install that module
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top