为google存储桶创建签名URL的问题



我正在尝试创建一个签名URL &运行它到丢失库pyopenssl问题。我的命令如下:

gsutil signurl -d 10d -u /Users/dineshc/Development/my_key.json gs://console.cloud.google.com/storage/browser/my_data

我得到以下错误:

commanddexception: signurl命令需要pyopenssl库(尝试pip install pyopenssl或easy_install pyopenssl)

我的操作系统配置如下:

uname      :    Darwin
ProductName:    macOS
ProductVersion: 11.4
BuildVersion:   20F71

I have python3.7 installed & I created symbolic link: 
ln -s /usr/local/bin/python3.7 /usr/local/bin/python
$ls -l /usr/local/bin/python*
lrwxr-xr-x  1 root  wheel  24  6 Oct 16:50 /usr/local/bin/python -> /usr/local/bin/python3.7
lrwxr-xr-x  1 root  wheel  69  6 Oct 16:04 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3
lrwxr-xr-x  1 root  wheel  76  6 Oct 16:04 /usr/local/bin/python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config
lrwxr-xr-x  1 root  wheel  71  6 Oct 16:04 /usr/local/bin/python3.7 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
lrwxr-xr-x  1 root  wheel  78  6 Oct 16:04 /usr/local/bin/python3.7-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config
lrwxr-xr-x  1 root  wheel  72  6 Oct 16:04 /usr/local/bin/python3.7m -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m
lrwxr-xr-x  1 root  wheel  79  6 Oct 16:04 /usr/local/bin/python3.7m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config
$python --version
Python 3.7.9
$which pip3
/usr/local/bin/pip3
$which pip
<nothing is coming up here but the command below shows that pip is installed>
$pip3 install pip
Requirement already satisfied: pip in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (21.2.4)
$pip install pyopenssl
-bash: pip: command not found

$pip3 install pyopenssl
Requirement already satisfied: pyopenssl in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (21.0.0)
Requirement already satisfied: six>=1.5.2 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pyopenssl) (1.16.0)
Requirement already satisfied: cryptography>=3.3 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from pyopenssl) (35.0.0)
Requirement already satisfied: cffi>=1.12 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from cryptography>=3.3->pyopenssl) (1.14.6)
Requirement already satisfied: pycparser in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from cffi>=1.12->cryptography>=3.3->pyopenssl) (2.20)
$echo $PATH
/Users/dineshc/Development/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
$ls -l /usr/local/bin/python*
lrwxr-xr-x  1 root  wheel  24  6 Oct 16:50 /usr/local/bin/python -> /usr/local/bin/python3.7
lrwxr-xr-x  1 root  wheel  69  6 Oct 16:04 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3
lrwxr-xr-x  1 root  wheel  76  6 Oct 16:04 /usr/local/bin/python3-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3-config
lrwxr-xr-x  1 root  wheel  71  6 Oct 16:04 /usr/local/bin/python3.7 -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
lrwxr-xr-x  1 root  wheel  78  6 Oct 16:04 /usr/local/bin/python3.7-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7-config
lrwxr-xr-x  1 root  wheel  72  6 Oct 16:04 /usr/local/bin/python3.7m -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m
lrwxr-xr-x  1 root  wheel  79  6 Oct 16:04 /usr/local/bin/python3.7m-config -> ../../../Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7m-config

我的问题:由于某种原因(我认为)gsutil仍然指的是python2.5,这是MacOS自带的版本&没有安装PIP。是否知道如何使gsutil使用最新版本的python &随后库吗?

您可以运行gsutil -D version并获得许多有用的调试信息,关于您的gsutil安装,用于运行它的Python版本,正在加载的配置文件等。

如果您正在运行gsutil的gcloud安装,您应该在输出中看到如下一行:

gsutil path: <path-to-google-cloud-sdk>/bin/gsutil

在这种情况下,您应该能够使用CLOUDSDK_GSUTIL_PYTHON环境变量指定您首选的Python解释器的路径,正如这些文档中提到的。

但是,如果您运行的是独立安装gsutil(不是gcloud安装的一部分),您应该确保通过命令/usr/bin/env python启动的Python版本是正确的版本——这将是从您的PATH环境变量中指定的目录中可发现的第一个Python二进制文件,因此您可能必须适当地编辑和export您的PATH

相关内容

  • 没有找到相关文章

最新更新