Pergunta

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?

Foi útil?

Solução

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.

Outras dicas

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
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top