Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

google-cloud 0.20.0 'from google.cloud import storage' not working #2464

Closed
VelizarVESSELINOV opened this issue Sep 29, 2016 · 20 comments
Closed
Assignees

Comments

@VelizarVESSELINOV
Copy link

After upgrade:

Collecting google-cloud
Collecting google-cloud-core>=0.20.0 (from google-cloud)
  Using cached google_cloud_core-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-language>=0.20.0 (from google-cloud)
  Using cached google_cloud_language-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-monitoring>=0.20.0 (from google-cloud)
  Using cached google_cloud_monitoring-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-storage>=0.20.0 (from google-cloud)
  Using cached google_cloud_storage-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-bigquery>=0.20.0 (from google-cloud)
  Using cached google_cloud_bigquery-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-error-reporting>=0.20.0 (from google-cloud)
  Using cached google_cloud_error_reporting-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-resource-manager>=0.20.0 (from google-cloud)
  Using cached google_cloud_resource_manager-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-vision>=0.20.0 (from google-cloud)
  Using cached google_cloud_vision-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-logging>=0.20.0 (from google-cloud)
  Using cached google_cloud_logging-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-translate>=0.20.0 (from google-cloud)
  Using cached google_cloud_translate-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-datastore>=0.20.0 (from google-cloud)
  Using cached google_cloud_datastore-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-dns>=0.20.0 (from google-cloud)
  Using cached google_cloud_dns-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-bigtable>=0.20.0 (from google-cloud)
  Using cached google_cloud_bigtable-0.20.0-py2.py3-none-any.whl
Collecting google-cloud-pubsub>=0.20.0 (from google-cloud)
  Using cached google_cloud_pubsub-0.20.0-py2.py3-none-any.whl
Collecting googleapis-common-protos>=1.3.4 (from google-cloud-core>=0.20.0->google-cloud)
  Downloading googleapis-common-protos-1.3.4.tar.gz
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.cloud import storage
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'storage'
@VelizarVESSELINOV VelizarVESSELINOV changed the title google-cloud 0.20.0 from google.cloud import storage not working google-cloud 0.20.0 'from google.cloud import storage' not working Sep 29, 2016
@dhermes
Copy link
Contributor

dhermes commented Sep 29, 2016

Yay packaging! Try pip show google-cloud-storage.

  1. What command did you use to install?
  2. What other google packages have you installed that may be hopping in front of your import?

@VelizarVESSELINOV
Copy link
Author

I moved today from 0.19.0 to 0.20.0 using pip install -r requirements.txt

after removing the virtual env and recreating again without update, it is working.

@dhermes
Copy link
Contributor

dhermes commented Sep 29, 2016

Great news! Thanks

@jlowin
Copy link

jlowin commented Oct 4, 2016

I also just upgraded from 0.19 to 0.20 with pip install --upgrade google-cloud and now can't import anything:

In [2]: from google.cloud import datastore
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-46f71c99c111> in <module>()
----> 1 from google.cloud import datastore

ImportError: cannot import name 'datastore'

Uninstall/reinstall had no effect.

@daspecster
Copy link
Contributor

daspecster commented Oct 4, 2016

@jlowin, since switching to namespace packages, you'll note in our CONTRIBUTING.rst that importing may not work as expected.

@dhermes, are there any workarounds so our examples work in the CLI REPL?

@jlowin
Copy link

jlowin commented Oct 4, 2016

@daspecster I used the same import statement in 0.19 without issue (from google.cloud import datastore)

@daspecster
Copy link
Contributor

@jlowin, if you put from google.cloud import datastore in a test_datastore.py file and run it with python test_datastore.py, does that also fail?

@jlowin
Copy link

jlowin commented Oct 4, 2016

Yes, that also failed -- but I think I've got it -- I had to uninstall both google-cloud and also protobuf, then let google-cloud reinstall protobuf.

@dhermes
Copy link
Contributor

dhermes commented Oct 4, 2016

@jlowin Can you do pip show google-cloud google-cloud-datastore?

@jlowin
Copy link

jlowin commented Oct 4, 2016

Sure, though after my last comment I think it won't be interesting :)

---
Metadata-Version: 2.0
Name: google-cloud
Version: 0.20.0
Summary: API Client library for Google Cloud
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google Cloud Platform
Author-email: [email protected]
Installer: pip
License: Apache 2.0
Location: /Users/jlowin/anaconda3/lib/python3.5/site-packages
Requires: google-cloud-language, google-cloud-bigquery, google-cloud-bigtable, google-cloud-datastore, google-cloud-dns, google-cloud-resource-manager, google-cloud-logging, google-cloud-translate, google-cloud-vision, google-cloud-pubsub, google-cloud-storage, google-cloud-monitoring, google-cloud-core, google-cloud-error-reporting
Classifiers:
  Development Status :: 4 - Beta
  Intended Audience :: Developers
  License :: OSI Approved :: Apache Software License
  Operating System :: OS Independent
  Programming Language :: Python :: 2
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Programming Language :: Python :: 3.4
  Programming Language :: Python :: 3.5
  Topic :: Internet
---
Metadata-Version: 2.0
Name: google-cloud-datastore
Version: 0.20.0
Summary: Python Client for Google Cloud Datastore
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google Cloud Platform
Author-email: [email protected]
Installer: pip
License: Apache 2.0
Location: /Users/jlowin/anaconda3/lib/python3.5/site-packages
Requires: google-cloud-core, grpcio
Classifiers:
  Development Status :: 4 - Beta
  Intended Audience :: Developers
  License :: OSI Approved :: Apache Software License
  Operating System :: OS Independent
  Programming Language :: Python :: 2
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Programming Language :: Python :: 3.4
  Programming Language :: Python :: 3.5
  Topic :: Internet

@jlowin
Copy link

jlowin commented Oct 4, 2016

Ok, I can create this error deterministically (on my machine at least):

pip uninstall google-cloud
pip install "google-cloud==0.19"
pip install google-cloud --upgrade
python -c "from google.cloud import datastore"

result:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name 'datastore'

@dhermes
Copy link
Contributor

dhermes commented Oct 4, 2016

Indeed.

$ virtualenv venv
$ source venv/bin/activate
(venv) $ venv/bin/pip install "google-cloud==0.19"
Collecting google-cloud==0.19
...
(venv) $ venv/bin/python -c "from google.cloud import datastore"
(venv) $ echo ${?}
0
(venv) $ venv/bin/pip install --upgrade google-cloud
Collecting google-cloud
...
(venv) $ venv/bin/python -c "from google.cloud import datastore"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: cannot import name datastore
(venv) $ venv/bin/pip freeze
enum34==1.1.6
future==0.15.2
futures==3.0.5
gapic-google-logging-v2==0.10.1
gapic-google-pubsub-v1==0.10.1
google-cloud==0.20.0
google-cloud-bigquery==0.20.0
google-cloud-bigtable==0.20.0
google-cloud-core==0.20.0
google-cloud-datastore==0.20.0
google-cloud-dns==0.20.0
google-cloud-error-reporting==0.20.0
google-cloud-language==0.20.0
google-cloud-logging==0.20.0
google-cloud-monitoring==0.20.0
google-cloud-pubsub==0.20.0
google-cloud-resource-manager==0.20.0
google-cloud-storage==0.20.0
google-cloud-translate==0.20.0
google-cloud-vision==0.20.0
google-gax==0.14.1
googleapis-common-protos==1.3.5
grpc-google-iam-v1==0.10.1
grpc-google-logging-v2==0.10.1
grpc-google-pubsub-v1==0.10.1
grpcio==1.0.0
httplib2==0.9.2
oauth2client==3.0.0
ply==3.8
protobuf==3.1.0.post1
pyasn1==0.1.9
pyasn1-modules==0.0.8
rsa==3.4.2
six==1.10.0

whereas installed just fresh

$ virtualenv venv
$ source venv/bin/activate
(venv) $ venv/bin/pip install --upgrade google-cloud
Collecting google-cloud
...
(venv) $ venv/bin/python -c "from google.cloud import datastore"
(venv) $ echo ${?}
0
(venv) $ venv/bin/pip freeze
enum34==1.1.6
future==0.15.2
futures==3.0.5
gapic-google-logging-v2==0.10.1
gapic-google-pubsub-v1==0.10.1
google-cloud==0.20.0
google-cloud-bigquery==0.20.0
google-cloud-bigtable==0.20.0
google-cloud-core==0.20.0
google-cloud-datastore==0.20.0
google-cloud-dns==0.20.0
google-cloud-error-reporting==0.20.0
google-cloud-language==0.20.0
google-cloud-logging==0.20.0
google-cloud-monitoring==0.20.0
google-cloud-pubsub==0.20.0
google-cloud-resource-manager==0.20.0
google-cloud-storage==0.20.0
google-cloud-translate==0.20.0
google-cloud-vision==0.20.0
google-gax==0.14.1
googleapis-common-protos==1.3.5
grpc-google-iam-v1==0.10.1
grpc-google-logging-v2==0.10.1
grpc-google-pubsub-v1==0.10.1
grpcio==1.0.0
httplib2==0.9.2
oauth2client==3.0.0
ply==3.8
protobuf==3.1.0.post1
pyasn1==0.1.9
pyasn1-modules==0.0.8
rsa==3.4.2
six==1.10.0

@dhermes
Copy link
Contributor

dhermes commented Oct 4, 2016

What's very strange is that pip freeze is identical.

Not sure what we can do though. It's likely a bug with pip or setuptools. All we can do is recommend a clean uninstall / fresh environment.

@jlowin
Copy link

jlowin commented Oct 4, 2016

bizarre and you're right, maybe nothing you can do! I'd at least recommend adding that note about the 0.19 -> 0.20 upgrade path to README though, I bet a lot of people will get bitten just through normal requirements.txt dependency installation! For what it's worth I continued the conversation at #2493 (comment) with the steps that resolved this for me.

@listentojohan
Copy link

I just encountered the same problem, but have had it working before.

Version: 1.2.0
Summary: Python Client for Google Cloud Storage
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google Cloud Platform
Author-email: [email protected]
License: Apache 2.0
Location: /usr/local/lib/python3.6/site-packages
Requires: google-resumable-media, google-auth, requests, google-cloud-core```

@listentojohan
Copy link

Uninstalling and doing a clean install did solve it.

@listentojohan
Copy link

listentojohan commented Apr 3, 2018

I am however now experiencing the same with a python:2 docker image using google.cloud storage.
Getting:
ImportError: Google Cloud Storage I/O not supported for this execution environment (could not import storage API client).

@VelizarVESSELINOV
Copy link
Author

Again after updating google-storage-cloud the package didn't work due to residual google packages with mismatch dependency.

Needed to delete all the old packages that pip3 uninstall google-cloud was ignoring using:
pip3 list | grep google | awk '{print $1}' | xargs pip uninstall -y

Hopefully one day Google will master pip or improve pip system.

@Ieshu
Copy link

Ieshu commented Jul 17, 2020

from google.cloud import bigtable

gives this error-->

ImportError: cannot import name 'init_grpc_aio' from 'grpc._cython.cygrpc' (C:\Users\PYTHON\lib\site-packages\grpc_cython\cygrpc.cp37-win_amd64.pyd)

@Lavedonio
Copy link

Had this weird problem where the from google.cloud import storage line would work in the Python interpreter but would spit out this error while running within a file.

Running pip install --upgrade google-cloud-storage was enough for it to be solved in my case. I guess it's indeed a bug in pip.

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

No branches or pull requests

7 participants