google-cloud-python: Error running "from google.cloud import storage" command
Thank you for reporting an issue to google-cloud-python!
If you are reporting an issue or requesting a feature, please search the existing open and closed issues to see if there is already work being done.
- https://github.com/GoogleCloudPlatform/google-cloud-python/issues
- http://stackoverflow.com/questions/tagged/google-cloud-python
If you can provide us with as much of the following information as possible it will help us identify the cause of your issue more quickly.
Hello, I’m hoping you can help. I’m trying to run the Python Client Library for Google Compute and running into issues. See below for my information. Thanks for any help you can provide.
1. OS type and version $ cat /etc/centos-release CentOS Linux release 7.4.1708 (Core)
2. Python version and virtual environment information python --version
$ python3 -V
Python 3.4.5
3. google-cloud-python version pip show google-cloud, pip show google-<service> or pip freeze
$ pip3 freeze | grep ^google
google-auth==1.1.1
google-cloud==0.27.0
google-cloud-bigquery==0.26.0
google-cloud-bigtable==0.26.0
google-cloud-core==0.26.0
google-cloud-datastore==1.2.0
google-cloud-dns==0.26.0
google-cloud-error-reporting==0.26.0
google-cloud-language==0.27.0
google-cloud-logging==1.2.0
google-cloud-monitoring==0.26.0
google-cloud-pubsub==0.27.0
google-cloud-resource-manager==0.26.0
google-cloud-runtimeconfig==0.26.0
google-cloud-spanner==0.26.0
google-cloud-speech==0.28.0
google-cloud-storage==1.3.2
google-cloud-translate==1.1.0
google-cloud-videointelligence==0.25.0
google-cloud-vision==0.26.0
google-gax==0.15.15
google-resumable-media==0.2.3
googleapis-common-protos==1.5.2
4. Stacktrace if available - See below
5. Steps to reproduce - from a fresh CentOS 7 VM in Google Compute, I ran the following commands: sudo yum -y install epel-release sudo yum -y install python34 sudo yum -y install python34-devel sudo yum -y install python34-setuptools sudo python3 /usr/lib/python3.4/site-packages/easy_install.py pip sudo pip3 install --upgrade pip pip3 install --upgrade google-cloud
- from python IDLE, ran the following command: from google.cloud import storage - error received: Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/usr/lib/python3.4/site-packages/google/cloud/storage/init.py”, line 37, in <module> from google.cloud.storage.batch import Batch File “/usr/lib/python3.4/site-packages/google/cloud/storage/batch.py”, line 29, in <module> from google.cloud import _helpers File “/usr/lib/python3.4/site-packages/google/cloud/_helpers.py”, line 33, in <module> from google.protobuf import duration_pb2 ImportError: No module named ‘google.protobuf’
6. Code example N/A Using GitHub flavored markdown can help make your request clearer. See: https://guides.github.com/features/mastering-markdown/
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (7 by maintainers)
Commits related to this issue
- chore: move samples from python-docs-sample (#33) * Add samples for DLP API v2beta1 [(#1369)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/1369) * Auto-update dependencies. [(... — committed to googleapis/google-cloud-python by arithmetic1728 4 years ago
- Update dependency google-cloud-pubsub to v1.6.0 [(#4039)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/4039) This PR contains the following updates: | Package | Update | Change ... — committed to googleapis/google-cloud-python by renovate-bot 4 years ago
- Update dependency google-cloud-pubsub to v1.6.0 [(#4039)](https://github.com/GoogleCloudPlatform/python-docs-samples/issues/4039) This PR contains the following updates: | Package | Update | Change ... — committed to googleapis/google-cloud-python by renovate-bot 4 years ago
Apparently the issue had to do with Amazon Linux AMI causing pip to import some packages to
venv/lib/python3.4/site-packages/and some tovenv/lib64/python3.4/site-packages, which I expect then caused problems because thegoogle/cloudmodules were underliband thegoogle/protobufmodule was underlib64.Here is a relevant link tracking the issue for pip, just in case anyone else runs into this issue with AWS EC2 instances: https://github.com/pypa/pip/issues/4464, and I solved this by including:
as container commands in
.ebextensionsWe’ve seen this issue quite a lot and it’s almost always caused by a “bad” install, i.e. one where the correct
.pthfiles don’t get created.@ep-tpat Try installing into a
virtualenv, so you can verify the install works. Then from your global install (i.e./usr/lib/python3.4/site-packages) you can work on fixing the issue. (Usually justpip install --ignore-installed protobufwill work.)I am pre-emptively closing this since it’s not an issue in our code (i.e. we can install it on lots of different machines) and it’s a common issue we’ve seen with
pipusage in the wild. I’m happy to re-open if this turns out to be something else.Feel free to keep asking questions in this issue though, we’re happy to help.