[英]Why can't I import the Google Cloud client library in Python?
I'm working in Python 2.7.10. 我正在使用Python 2.7.10。
i'm just trying to run from google.cloud import storage
, but I get ImportError: No module named google.cloud
. 我只是想from google.cloud import storage
运行,但是我得到ImportError: No module named google.cloud
。
google-cloud appears to be installed correctly. google-cloud似乎已正确安装。 pip install google-cloud
returns Requirement already satisfied: google-cloud in /Library/Python/2.7/site-packages (0.34.0)
, and pip show google-cloud
returns: pip install google-cloud
返回Requirement already satisfied: google-cloud in /Library/Python/2.7/site-packages (0.34.0)
pip show google-cloud
,并且pip show google-cloud
返回:
Name: google-cloud
Version: 0.34.0
Summary: API Client library for Google Cloud
Home-page: https://github.com/GoogleCloudPlatform/google-cloud-python
Author: Google Cloud Platform
Author-email: googleapis-publisher@google.com
License: Apache 2.0
Location: /Library/Python/2.7/site-packages
Requires:
Required-by:
EDIT: thanks to Duy below for reminding me about the next step. 编辑:感谢下面的Duy提醒我有关下一步的信息。 Running pip install google-cloud-storage
throws a bunch of errors: 运行pip install google-cloud-storage
会引发很多错误:
Using cached https://files.pythonhosted.org/packages/7b/7c/c9386b82a25115cccf1903441bba3cbadcfae7b678a20167347fa8ded34c/pyasn1-0.4.5-py2.py3-none-any.whl
protobuf 3.6.1 has requirement six>=1.9, but you'll have six 1.4.1 which is incompatible.
google-api-core 1.7.0 has requirement six>=1.10.0, but you'll have six 1.4.1 which is incompatible.
google-auth 1.6.2 has requirement six>=1.9.0, but you'll have six 1.4.1 which is incompatible.
Installing collected packages: setuptools, protobuf, googleapis-common-protos, urllib3, certifi, chardet, idna, requests, futures, pyasn1, rsa, pyasn1-modules, cachetools, google-auth, google-api-core, google-cloud-core, google-resumable-media, google-cloud-storage
Found existing installation: setuptools 18.5
Uninstalling setuptools-18.5:
Could not install packages due to an EnvironmentError: [('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc', "[Errno 1] Operation not permitted: '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py', "[Errno 1] Operation not permitted: '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py', "[Errno 1] Operation not permitted: '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/markers.py'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc', "[Errno 1] Operation not permitted: '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib/__init__.pyc'"), ('/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib', "[Errno 1] Operation not permitted: '/private/var/folders/_h/5cqnls4d2jxckyjk70267q_c0000gp/T/pip-uninstall-ZBmwkH/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/_markerlib'")]
I don't understand what the environment error is, and all my searches run down unhelpful rabbit holes. 我不了解环境错误是什么,我所有的搜索都遇到了无益的兔子洞。
google-cloud
包已被弃用,您应该将其卸载并安装google-cloud-storage
。
You must use a python environment. 您必须使用python环境。
pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install google-cloud-python
Check here for more details about virtualenv
https://cloud.google.com/python/setup 在此处查看有关virtualenv
更多详细信息https://cloud.google.com/python/setup
您忘记安装pip install google-cloud-storage
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.