question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: No module named appengine.api (even after app-engine-python installation)

See original GitHub issue

Hi,

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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:28 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
mhdtoubancommented, Sep 28, 2018

Try to use miniconda conda.io/miniconda

On Thu, Sep 27, 2018, 9:57 PM Evan Fir notifications@github.com wrote:

You need to add the following to your ~/.bash_profile file

export GOOGLE_APP_ENGINE_DIR=/usr/local/google_appengine

I tried this and I’m still getting the same error. I don’t use virtual environment. MacOS Sierra 10.12.6 (16G1510) Python 3.7.0

β€” You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GoogleCloudPlatform/getting-started-python/issues/157#issuecomment-425305389, or mute the thread https://github.com/notifications/unsubscribe-auth/ACYvDw2hVWlB_1YQQ0ZoISz01oGTVKggks5ufZAkgaJpZM4S7ocQ .

9reactions
michaelawyucommented, Jan 23, 2020

Hi everyone!

In most cases Cloud SDK or the package manager on your system installs packages app-engine-python and app-engine-python-extras inside 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 your PYTHONPATH, 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_appengine to your PYTHONPATH. More specifically, run the command below:

export PYTHONPATH=${PYTHONPATH}:$(gcloud info --format="value(installation.sdk_root)")/platform/google_appengine

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.mypackage and google.appengine.api in 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__.py is 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 correct PYTHONPATH settings, check your site-packages folder and make sure that the __init__.py script under the google folder is corrected set.

michaelawyu

Read more comments on GitHub >

github_iconTop Results From Across the Web

python import error "No module named appengine.ext"
The pip install created a python package google which didn't contain the appengine submodule (which is found in the SDK folder).
Read more >
Fixing python import error β€œNo module named appengine”
If it throws an import error, it means that either the App Engine SDK is not installed, or at least the Python run-time...
Read more >
No module named google.appengine.api module with the ...
I installed glcoud SDK according to the docs and installed the appengine python components from command line. I ran the commands below and...
Read more >
app-engine-python 1.9.95 upgrade results in "ImportError ...
remote_api_shell.py still not working with latest SDK. I get an error "No module named yaml". After installing pyyaml, I get "No module named...
Read more >
Using Python 2 libraries - App Engine - Google Cloud
You can still add matplotlib to the libraries list, but it will raise an ImportError exception when imported. Matplotlib is a plotting library...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found