Im getting this error when testing my main.py GAE application:
Traceback (most recent call last):
File "main.py", line 4, in <module>
from google.appengine.ext import db
ImportError: No module named google.appengine.ext
I read a lot about it but i can´t find the answer...any ideas or help? Thank you guys!!
I had the same problem when testing my app. I found that my /usr/local/google_appengine
contained the google
python module, so I added that path to my $PYTHONPATH
environment variable. You can do this in 2 ways:
In your console, type export PYTHONPATH="$PYTHONPATH:/usr/local/google_appengine"
. This will add it to your PYTHONPATH for this console session.
In your shell profile file (perhaps ~/.bash_profile
), add a line like this:
export PYTHONPATH="$PYTHONPATH:/usr/local/google_appengine"
Then either open a new console session or reload your profile with source ~/.bash_profile
(or whatever your file is)
You may have to modify this because a) your "google_appengine" folder is in a different location (not /usr/local
) or b) your OS separates paths differently (I think windows uses ;
instead of :
-- I'm on a Mac)
I would like to add a case that I have faced. My OS is MAC.
The Google App Engine would create a link under /usr/local/google_appengine
.
I added the above path to PYTHONPATH
, it still don't work. After some trail, I found I had installed protobuf which is also under development of google, please check
https://developers.google.com/protocol-buffers/docs/pythontutorial
It will create a folder under side_packages
also named google
. So if you try to import google
, it is actually importing protobuf.
So one possible solution for this is temporarily uninstall protobuf:
pip uninstall protobuf
It seems that the problem come from the directory /google_appengine
that is not always at the right spot, so python cannot find it (through PYTHONPATH
).
Find the location of the google_appengine directory by running
find / -name google_appengine -type d
Once you found it (e.g. : /usr/lib/google-cloud-sdk/platform/google_appengine
), run:
export PYTHONPATH=:/usr/lib/google-cloud-sdk/platform/google_appengine
This solved my problem.
It's not the answer, but can you try adding the following code to debug:
import logging
import google
logging.info("google path: {}.".format(google.__file__))
Compare this path to the location of the App Engine SDK.
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