gcloud command suddenly doesn't work at all - google-cloud-platform

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.

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

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)

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.

Related

Cannot import sklearn_pandas in Google AI Platform Notebook after pip install

I am playing around with Google's AI Platform Notebook (which is still in beta at the moment). I uploaded a python script that has dependency on sklearn_pandas and I am getting this error:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-24f79569b871> in <module>
----> 1 from sklearn_pandas import DataFrameMapper
ImportError: No module named 'sklearn_pandas'
I then try to pip install it:
!pip install sklearn-pandas
I restarted the kernel but it is still getting same ImportError. I did this to confirm sklearn pandas is really installed:
!pip list |grep -i sklearn
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
sklearn-pandas (1.8.0)
Anyone has tried this? I used google colab before this, and I never have such difficulty. It will be great if Google colab level of user experience can be ported into this beta product. I think this could be a general python module importing issue than just sklearn_pandas in particular.
i think it may be
%pip install sklearn-pandas
instead of "!pip".

"ImportError: No module named path" showing when running software in ubuntu 12.04

I am running one software in ubuntu 12.04. It requires python. I have python 2.7.3 on ubuntu. When try to run command ./cmdsadit sim -c ./Example/SimExample.py it shows following
jayram#ubuntu:~/sadit$ ./cmdsadit sim -c ./Example/SimExample.py
[warning] socketIO_client is not found. Real-time ability is disabled
--> Use [matplotlib] as plot backend
--> [warning] cannot import sql related function, reading for sql server is not supported
WARNING:util:Cannot find [socketIO_client], real-time ability is disabled.
WARNING:util:Cannot import sql related function, reading for sql server is not supported
Traceback (most recent call last):
File "fs.py", line 10, in <module>
from networkx.algorithms.traversal.path import single_source_dijkstra_path, dijkstra_path_length
ImportError: No module named path
jayram#ubuntu:~/sadit$
Some initial line screenshot of fy.py file is given below
How do I solve this error?
The error is self explanatory, your import from path module is incorrect
It should be
from networkx.algorithms import single_source_dijkstra_path, dijkstra_path_length

ImportError: no module named pwd in app engine

I'm trying to run a python flask based application on google app engine using cloud datastore. I'm following the bookshelf example -
https://cloud.google.com/python/getting-started/using-cloud-datastore
Everything seems to work in local machine but on app engine, I'm getting
ImportError: No module named pwd, which is being imported by oauth2client library.
Is there anything I'm missing. Any help will be appreciated.
The question referenced as duplicate is different. The application there seems to fail only locally, whereas for me everything works locally but fails to work in GAE.
Here's the stack trace (partial) -
...
1384/v1.394932573930853146/application/home/model.py", line 16, in save_user
ds = get_client()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/application/home/model.py", line 7, in get_client
return datastore.Client('bookshelf-1384')#current_app.config['PROJECT_ID'])
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/gcloud/datastore/client.py", line 173, in __init__
super(Client, self).__init__(credentials, http)
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/gcloud/client.py", line 122, in __init__
credentials = get_credentials()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/gcloud/credentials.py", line 82, in get_credentials
return client.GoogleCredentials.get_application_default()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/oauth2client/client.py", line 1288, in get_application_default
return GoogleCredentials._get_implicit_credentials()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/oauth2client/client.py", line 1273, in _get_implicit_credentials
credentials = checker()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/oauth2client/client.py", line 1226, in _implicit_credentials_from_files
credentials_filename = _get_well_known_file()
File "/base/data/home/apps/s~bookshelf-1384/v1.394932573930853146/lib/oauth2client/client.py", line 1392, in _get_well_known_file
default_config_dir = os.path.join(os.path.expanduser('~'),
File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/posixpath.py", line 268, in expanduser
import pwd
ImportError: No module named pwd
The error is caused by http://github.com/google/oauth2client/issues/578.
It will be fixed in a couple of weeks with a new AppEngine SDK. In the meantime you can downgrade the version of the oauth2client library in your app.yaml file.
I had this same issue which is a known issue with the SDK. I tried the other solutions suggested on SO (see Google App Engine 'No module named pwd') but it didn't work. I found a work around by installing an older version of oauth2client-2.0.0 overwriting the oauth2client-4.0.0 that came with the pubsub pip install. Try running
pip install -t ./lib/ --upgrade --force-reinstall oauth2client==2.0.0
in the project directory and rerunning.

Virtual env Python packages with Google Cloud SDK

I'm in the Getting Started section of Google Cloud SDK from Dan Sanderson's book, sorry no link.
The thing is I created a clock application with the local installation of Python.
Then I created a virtual environment, and ran the same application with the corresponding installation.
I installed the packages that I needed, but I get a strange error about -what I think- is one of the base Python packages.
(myenv) diego#host:gae-clock$ dev_appserver.py .
Traceback (most recent call last):
File ".../google-cloud-sdk/bin/dev_appserver.py", line 11, in <module>
import bootstrapping.bootstrapping as bootstrapping
File ".../google-cloud-sdk/bin/bootstrapping/bootstrapping.py",
line 9, in <module>
import setup
ImportError: No module named 'setup'
thank you for pointing in the right direction. Please let me know if I can show more to track this down.

Python import error when using PBS

My institute has some parallel computers with CentOS release 6.4 and Python2.6 installed. I want to use python 2.7, then I installed python 2.7.11 locally (without root permission, because I am not a root). My problem is that when I use Portable Batch System (PBS) to run python scripts, some import statements raise errors while packages were definitely installed (locally). For more detail, my scripts are:
test.py:
import ssl
test.pbs:
#!/bin/csh
cd working_dir
python test.py
When I run python test.py, no errors displayed.
When I submit the PBS job qsub test.pbs, the job was started and ended with error:
Traceback (most recent call last):
File "test.py", line 1, in
import ssl
File "/home/s1310007/python/lib/python2.7/ssl.py", line 97, in
import _ssl # if we can't import it, let the error propagate
ImportError: /home/s1310007/python/lib/python2.7/lib-dynload/_ssl.so: symbol SSL_get0_next_proto_negotiated, version libssl.so.10 not defined in file libssl.so.10 with link time reference
I guess when I ran python test.py on the login node (I logged in using ssh), the environment paths were set correctly. When the PBS job was started, the different environment paths were set, then the dynamic symbol SSL_get0_next_proto_negotiated was not resolved. I tried to modify my .cshrc or .dtprofile, .modulesbeginenv; but nothing works. Any suggestions? Thanks!