简体   繁体   English

为什么我不能在Python中导入Google Cloud客户端库?

[英]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.

相关问题 为什么MATLAB不能导入这个python库? - why can't MATLAB import this python library? 为什么我不能在 Google Colab 中导入 python-rosbag? - Why can't I import python-rosbag in Google Colab? 为什么我不能导入任何库? - Why I can't import any library? Gitlab CI Runner无法以Python导入Google.Cloud - Gitlab CI Runner can't import Google.Cloud in Python 无法在 Google App Engine 中导入 ctypes python 库 - Can't import the ctypes python library in Google App Engine Gmail API 快速入门:无法安装 Python Google 客户端库 - Gmail API Quickstart: Can't install Python Google Client Library 无法在Android项目中导入Google Cloud Endpoints客户端库类 - Cannot import google cloud endpoints client library class in Android project 为什么我不能在 python 中导入一个类? - Why I can´t import a class in python? 为什么我不能使用 Python(使用此代码)通过 MQTT 将图像发送到 Google Cloud IoT Core? - Why can't I send image to Google Cloud IoT Core with MQTT using Python (with this code)? 如何使用适用于 Cloud Functions 的 Google Python 客户端获取 Google Cloud Functions 的列表? - How can I get a list of Google Cloud Functions using Google Python Client for Cloud Functions?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM