4

All gcloud commands suddenly give this error:

ERROR: gcloud failed to load: No module named google.appengine.ext

This usually indicates corruption in your gcloud installation or problems with your Python interpreter.

Please verify that the following is the path to a working Python 2.7 executable: /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python

If it is not, please set the CLOUDSDK_PYTHON environment variable to point to a working Python 2.7 executable.

If you are still experiencing problems, please reinstall the Cloud SDK using the instructions here: https://cloud.google.com/sdk/

Here are some relevant details and things that I've tried:

  • Mac 10.11.6
  • Python 2.7.8 at /Library/Frameworks/Python.framework/Versions/2.7/bin/python
  • Python otherwise works fine
  • I completely removed google-cloud-sdk and redownloaded from https://cloud.google.com/sdk/
  • Tried rebooting
  • Tried "export CLOUDSDK_PYTHON=/Library/Frameworks/Python.framework/Versions/2.7/bin/python" but it didn't help. Also added this line to my .bash_profile

Anyone else having this problem or can suggest a fix?


I have a fix below, but I'll happily award the answer to anyone who can explain what is going on.

new name
  • 15,861
  • 19
  • 68
  • 114

3 Answers3

12

I had the same issue . I solved it by using the default python2.7 in Ubuntu

Type this in termimal

export CLOUDSDK_PYTHON=/usr/bin/python

Not sure if this will work the same on Windows

Crystal Ophaso
  • 129
  • 1
  • 3
  • 1
    This didn't work for me at first. I had to use "whereis python" command, and that got me this path: "/usr/bin/python2.7". So I used it in the export command and it worked! – nanocv May 23 '22 at 16:09
5

I followed the answer here, worked for me https://stackoverflow.com/a/59816812/2210667

brew switch openssl 1.0.2q (or whatever latest version you have from ls /usr/local/Cellar/openssl)

Thomas
  • 8,306
  • 8
  • 53
  • 92
0

I figured out what was causing the problem, though I don't understand what is going on... When reinstalling gcloud I skipped the install script (./google-cloud-sdk/install.sh) since it is an optional step and I already had the needed lines in my bash profile.

When running this script, however, I got this error:

$ ./google-cloud-sdk/install.sh
Welcome to the Google Cloud SDK!
Traceback (most recent call last):
  File "/Users/.../google-cloud-sdk/bin/bootstrapping/install.py", line 8, in <module>
    import bootstrapping
  File "/Users/.../google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 17, in <module>
    import oauth2client.contrib.gce as gce
  File "/Users/.../google-cloud-sdk/lib/third_party/oauth2client/contrib/gce.py", line 23, in <module>
    import httplib2
  File "/Users/.../google-cloud-sdk/lib/third_party/httplib2/__init__.py", line 29, in <module>
    import email
  File "/Users/.../GIT/GAE_Project/email.py", line 1, in <module>
ImportError: No module named google.appengine.ext

A file I recently created in my GAE project named email.py broke gcloud!?! Renaming this file fixed gcloud.

This is my PYTHONPATH:

/Users/.../google-cloud-sdk/platform/google_appengine:/Users/.../GIT/GAE_Project

So even though the Google cloud libraries come before my GAE project in my PYTHONPATH, a file in my GAE project broke gcloud.

new name
  • 15,861
  • 19
  • 68
  • 114