문제

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