I'm working with a Google App Engine project and within the project I am unable to use this import:
import resource
I receive this error:
ImportError: No module named resource
However, if I fire up the terminal and run this code it works fine:
$ python
Python 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import resource
The root folder of the project does not have an _init_.py file which is what many of the other answers suggest. I use Aptana 3, OSX 10.8.2 and Python 2.7.3.
Why would the import not work in my website, but does work in the interpreter?
You need to put resource.py, or the folder resource in your application's directory. GAE uses a different interpreter and therefore doesn't have the modules you installed on your computer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With