Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Install google-cloud-python not working? #2366

Closed
hohaichi opened this issue Sep 20, 2016 · 14 comments
Closed

Install google-cloud-python not working? #2366

hohaichi opened this issue Sep 20, 2016 · 14 comments
Assignees

Comments

@hohaichi
Copy link

hohaichi commented Sep 20, 2016

Does anyone know if how to install google-cloud python client library? I tried the pip command below, which succeeded, but it still seems like something is missing. from google.cloud import storage complains that cloud module doesn't exist. Thanks.

$ sudo pip install --upgrade google-cloud
Requirement already up-to-date: google-cloud in /usr/local/lib/python2.7/dist-packages/google_cloud-0.19.0-py2.7.egg
Requirement already up-to-date: httplib2>=0.9.1 in /usr/local/lib/python2.7/dist-packages (from google-cloud)
Requirement already up-to-date: googleapis-common-protos in /usr/local/lib/python2.7/dist-packages (from google-cloud)
Requirement already up-to-date: oauth2client>=2.0.1 in /usr/local/lib/python2.7/dist-packages (from google-cloud)
Requirement already up-to-date: protobuf>=3.0.0 in /usr/local/lib/python2.7/dist-packages (from google-cloud)
Requirement already up-to-date: six in /usr/local/lib/python2.7/dist-packages (from google-cloud)
Requirement already up-to-date: grpcio>=1.0.0 in /usr/local/lib/python2.7/dist-packages (from google-cloud)
Requirement already up-to-date: google-gax<0.14dev,>=0.13.0 in /usr/local/lib/python2.7/dist-packages/google_gax-0.13.0-py2.7.egg (from google-cloud)
Requirement already up-to-date: gapic-google-pubsub-v1<0.10dev,>=0.9.0 in /usr/local/lib/python2.7/dist-packages/gapic_google_pubsub_v1-0.9.1-py2.7.egg (from google-cloud)
Requirement already up-to-date: grpc-google-pubsub-v1<0.10dev,>=0.9.0 in /usr/local/lib/python2.7/dist-packages/grpc_google_pubsub_v1-0.9.0-py2.7.egg (from google-cloud)
Requirement already up-to-date: gapic-google-logging-v2<0.10dev,>=0.9.0 in /usr/local/lib/python2.7/dist-packages/gapic_google_logging_v2-0.9.1-py2.7.egg (from google-cloud)
Requirement already up-to-date: grpc-google-logging-v2<0.10dev,>=0.9.0 in /usr/local/lib/python2.7/dist-packages/grpc_google_logging_v2-0.9.0-py2.7.egg (from google-cloud)
Requirement already up-to-date: pyasn1>=0.1.7 in /usr/local/lib/python2.7/dist-packages (from oauth2client>=2.0.1->google-cloud)
Requirement already up-to-date: pyasn1-modules>=0.0.5 in /usr/local/lib/python2.7/dist-packages (from oauth2client>=2.0.1->google-cloud)
Requirement already up-to-date: rsa>=3.1.4 in /usr/local/lib/python2.7/dist-packages (from oauth2client>=2.0.1->google-cloud)
Requirement already up-to-date: enum34>=1.0.4 in /usr/local/lib/python2.7/dist-packages (from grpcio>=1.0.0->google-cloud)
Requirement already up-to-date: futures>=2.2.0 in /usr/local/lib/python2.7/dist-packages (from grpcio>=1.0.0->google-cloud)
Requirement already up-to-date: future>=0.15.2 in /usr/local/lib/python2.7/dist-packages (from google-gax<0.14dev,>=0.13.0->google-cloud)
Requirement already up-to-date: ply==3.8 in /usr/local/lib/python2.7/dist-packages (from google-gax<0.14dev,>=0.13.0->google-cloud)
Cleaning up...

But on import

$ python -c "from google.cloud import storage"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/buildtools/current/sitecustomize/sitecustomize.py", line 181, in SetupPathsAndImport
    return real_import(name, globals, locals, fromlist, level)
ImportError: No module named cloud
@dhermes
Copy link
Contributor

dhermes commented Sep 20, 2016

Your sitecustomize may be to blame there.

First you should do a pip show google-cloud to make sure it's there and to check out the Location:.

@hohaichi
Copy link
Author

hohaichi commented Sep 20, 2016

The output from pip show google-cloud looks good to me:

$ sudo pip show google-cloud
Name: google-cloud
Version: 0.19.0
Location: /usr/local/lib/python2.7/dist-packages/google_cloud-0.19.0-py2.7.egg
Requires: httplib2, googleapis-common-protos, oauth2client, protobuf, six, grpcio, google-gax, gapic-google-pubsub-v1, grpc-google-pubsub-v1, gapic-google-logging-v2, grpc-google-logging-v2

And package storage is there:

$ ls /usr/local/lib/python2.7/dist-packages/google_cloud-0.19.0-py2.7.egg/google/cloud/storage/
acl.py          batch.py        blob.py         bucket.py       client.py       connection.py   _helpers.py     __init__.py
acl.pyc         batch.pyc       blob.pyc        bucket.pyc      client.pyc      connection.pyc  _helpers.pyc    __init__.pyc

Do you know how to fix the issue with sitecustomize?

@hohaichi
Copy link
Author

hohaichi commented Sep 20, 2016

My problem has been resolved---thanks to our colleague Brian Call at techstop.

The problem is that before using pip I tried install google-cloud manually by downloading the source and running setup.py:

$ git clone https://github.com/GoogleCloudPlatform/google-cloud-python.git
$ cd google-cloud-python
$ python setup.py build
$ sudo python setup.py install
...
Installed /usr/local/lib/python2.7/dist-packages/google_cloud-0.19.0-py2.7.egg

We removed everything in /usr/local/lib/python2.7/dist-packages/* and reinstalled google-cloud. It went like this (notes, we needed to use sudo):

(1) pip install google-cloud
(protobuf version issue, need >=3.0.0)

(2) pip install --upgrade protobuf
(permissions issue)

(3) sudo pip install --upgrade protobuf
(success)

(4) pip install google-cloud
(fail, permissions)

(5) sudo pip install --upgrade google-cloud
(success)

Now google-cloud is in /usr/local/lib/python2.7/dist-packages rather than /usr/local/lib/python2.7/dist-packages/google_cloud-0.19.0-py2.7.egg:

$ pip show google-cloud
---
Name: google-cloud
Version: 0.19.0
Location: /usr/local/lib/python2.7/dist-packages
Requires: httplib2, googleapis-common-protos, oauth2client, protobuf, six, grpcio, google-gax, gapic-google-pubsub-v1, grpc-google-pubsub-v1, gapic-google-logging-v2, grpc-google-logging-v2

And google.cloud works:

$ python -c "from google.cloud import storage"
$

@dhermes
Copy link
Contributor

dhermes commented Sep 20, 2016

Good deal. A few more tips.

  1. If you can, you should stop using sudo pip and just work in virtualenvs
  2. If you must, use -H, i.e. sudo -H pip ...

@kaangiray26
Copy link

I had the same problem.My problem caused by pip.Pip was installing google-cloud in the wrong directory.
I used python -m pip install google-cloud instead and it worked!

@ravi133
Copy link

ravi133 commented May 15, 2018

no module name error : google not found even after installing it from pip command. do i need to do the authentication process before import

@andkamau
Copy link

Post-June'18:
the "google-cloud" python package has been deprecated.

You should install your product-specific package
pip install google-cloud-{x}

@dmvtmn
Copy link

dmvtmn commented Sep 5, 2018

Hi,
so I did this:
Requirement already up-to-date: google-cloud-bigquery in /usr/local/lib/python3.5/dist-packages (1.5.0)
but now when trying to run the import I get a syntax error:
File "<string>", line 1 import google-cloud-bigquery ^ SyntaxError: invalid syntax

Can you please help? any suggestions?

@tseaver
Copy link
Contributor

tseaver commented Sep 5, 2018

@dmvtmn google-cloud-bigquery names the distribution installed by pip: it installs software into the
package, google.cloud.bigquery. So,

$ pip install google-cloud-bigquery

but

import google.cloud.bigquery

@demongolem
Copy link

demongolem commented Oct 2, 2018

I am having same problem with 0.34.0. The python -m pip install google-cloud says Requirement already satisifed: google-cloud, however when I go to the named directory, all I see is a single folder within google, and that is protobuf. The package I wanted to install was google-cloud-language and using this specific package did it for me

@tseaver
Copy link
Contributor

tseaver commented Oct 2, 2018

@demongolem The google-cloud umbrella package is deprecated -- it can no longer be used to install any of the "real" API libraries. Instead, just pip install google-cloud-language.

@monajalal
Copy link

monajalal commented Mar 24, 2019

I want to use Google Cloud Natural Language for Entity Recognition and Sentiment Analysis. I get the following error:

[jalal@goku sentiment]$  pip install --user  --upgrade google-cloud
Collecting google-cloud
  Downloading https://files.pythonhosted.org/packages/ba/b1/7c54d1950e7808df06642274e677dbcedba57f75307adf2e5ad8d39e5e0e/google_cloud-0.34.0-py2.py3-none-any.whl
Installing collected packages: google-cloud
Successfully installed google-cloud-0.34.0
[jalal@goku sentiment]$ python sentiment.py 
Traceback (most recent call last):
  File "sentiment.py", line 20, in <module>
    from google.cloud import language
ModuleNotFoundError: No module named 'google.cloud'
[jalal@goku sentiment]$ python -m pip install google-cloud
Requirement already satisfied: google-cloud in /home/grad3/jalal/.local/lib/python3.6/site-packages (0.34.0)

More information here: https://stackoverflow.com/questions/55328328/from-google-cloud-import-language-modulenotfounderror-no-module-named-google-c

@tseaver
Copy link
Contributor

tseaver commented Mar 26, 2019

@monajalal Please don't use the long-deprecated "umbrella" google-cloud distribution: instead, install just the API library(ies) that you need. In your case:

$  pip install --user  --upgrade google-cloud-language

@akkhil7
Copy link

akkhil7 commented Jul 7, 2019

--user flag helped in my case. Thank you @tseaver

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

10 participants