Skip to main content
 首页 » 编程设计

python之从 GCloud 激活服务帐户

2025年05月04日7think

我正在尝试配置 notification for a Google Cloud Storage bucket object change但是,当我试图让 gsutil 通过此命令使用服务帐户时,我遇到了困难。

gcloud auth activate-service-account service-account-email --key-file path/to/key.p12 

我在命令行中得到的错误是:

ERROR: (gcloud.auth.activate-service-account) PyOpenSSL is not available. If you have already installed PyOpenSSL, you will need to enable site packages by setting the environment variable CLOUDSDK_PYTHON_SITEPACKAGES to 1. If that does not work, See https://developers.google.com/cloud/sdk/crypto for details. 

我关注了this instructions to get pyOpenSSL .如果我向 pip 询问该软件包,它会告诉我它已安装

$ pip show pyopenssl 
--- 
Name: pyOpenSSL 
Version: 0.14 
Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages 
Requires: cryptography, six 

如果我调用 env 命令,我也会看到环境变量

$ env 
... 
CLOUDSDK_PYTHON_SITEPACKAGES=1 

我做错了什么吗?

请您参考如下方法:

这表明 PyOpenSSL 没有正确安装。由于PyOpenSSL包含cryptoroutine,Cloud SDK无法轻松打包,依赖第三方安装。