ImportError: No module named appengine.api (even after app-engine-python installation)
See original GitHub issueHi,
I used a newly created CentOS7 VM in Google Cloud Platform to try to run the following Python code (Python version: 2.7.5):-
from google.appengine.api import urlfetch
But I got this error message:-
ImportError: No module named appengine.api
Previously, I already have already installed app-engine-python and app-engine-python-extras in gcloud. For example, if I now run this:-
yum install google-cloud-sdk-app-engine-python
I would get this to tell me that it is already installed:-
Package google-cloud-sdk-app-engine-python-194.0.0-1.noarch already installed and latest version Nothing to do
And if I now run this:-
gcloud components list
Again, I would get this to tell me that the app-engine components are already installed:-
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β Components
β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ¬βββββββββββ
β€
β Status β Name β ID β Size
β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββΌβββββββββββ
(...............................................................................)
(skipped showing other gcloud components)
(...............................................................................)
β Installed β gcloud app Python Extensions β app-engine-python β 6.2 MiB
β
β Installed β gcloud app Python Extensions (Extra Libraries) β app-engine-python-extras β 27.8 MiB
β
ββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββ΄βββββββββββ
I tried to download pip and use pip to install the stuff again, and I if I run pip freeze | grep ^google I would get this (without showing app-engine ?):-
google-api-core==0.1.4
google-auth==1.4.1
google-cloud-bigquery==0.28.0
google-cloud-bigquery-datatransfer==0.1.1
google-cloud-container==0.1.1
google-cloud-core==0.28.1
google-cloud-datastore==1.4.0
google-cloud-dns==0.28.0
google-cloud-firestore==0.28.0
google-cloud-language==1.0.1
google-cloud-monitoring==0.28.1
google-cloud-speech==0.30.0
google-cloud-trace==0.17.0
google-cloud-translate==1.3.1
google-cloud-vision==0.29.0
google-compute-engine==2.7.6
google-gax==0.15.16
google-resumable-media==0.3.1
googleapis-common-protos==1.5.3
How can I get it solved? I just want to run from google.appengine.api import urlfetch successfully.
Thanks in advance!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:28 (1 by maintainers)

Top Related StackOverflow Question
Try to use miniconda conda.io/miniconda
On Thu, Sep 27, 2018, 9:57 PM Evan Fir notifications@github.com wrote:
Hi everyone!
In most cases Cloud SDK or the package manager on your system installs packages
app-engine-pythonandapp-engine-python-extrasinside Cloud SDK itself, i.e. if your Cloud SDK resides in/usr/lib64/google-cloud-sdk/, the packages will only be available in/usr/lib64/google-cloud-sdk/platform/google_appengine. Cloud SDK will NOT add this directory to yourPYTHONPATH, thus Python will not search this location for said packages and will return the errors reported.To fix this issue, simply add
YOUR-CLOUD-SDK-INSTALLATION/platform/google_appengineto yourPYTHONPATH. More specifically, run the command below:Additionally, note that Python will only search the first matched directory in the given paths without further instructions. For example, if you imported both
google.mypackageandgoogle.appengine.apiin your script and these two packages live in two separate places, Python will report an error for either of them as it cannot find both in the same place. This should not be an issue for most Google Cloud Client Libraries, since their__init__.pyis specified with__path__ = pkgutil.extend_path(__path__, __name__), which extends the path and tells Python to continue searching in the case of a mismatch. Should your error persists despite correctPYTHONPATHsettings, check yoursite-packagesfolder and make sure that the__init__.pyscript under thegooglefolder is corrected set.michaelawyu