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!!
Following code will print all google python lib paths
running the code on my machine prints this
this is not the same as looking for google appengine installation directories. On my mac, the installer creates sym links
incase you are unit testing, you probably need to add the path to your code
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 checkhttps://developers.google.com/protocol-buffers/docs/pythontutorial
It will create a folder under
side_packages
also namedgoogle
. So if you try toimport google
, it is actually importing protobuf.So one possible solution for this is temporarily uninstall protobuf:
pip uninstall protobuf
I had the same problem when testing my app. I found that my
/usr/local/google_appengine
contained thegoogle
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: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)It's not the answer, but can you try adding the following code to debug:
Compare this path to the location of the App Engine SDK.
It seems that the problem come from the directory
/google_appengine
that is not always at the right spot, so python cannot find it (throughPYTHONPATH
).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.