Dinesh
Dinesh

Reputation: 327

Issue creating Signed URL for google storage bucket

I am trying to create a Signed URL & run it into missing library pyopenssl issue. My command is the following one:

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

I am getting following error:

CommandException: The signurl command requires the pyopenssl library (try pip install pyopenssl or easy_install pyopenssl)

My OS configuration is the following one:

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

My issue: For some reason (I think) gsutil is still referring to python2.5, which is the version that comes with MacOS & does not have pip installed. Any idea how to make gsutil use the latest version of python & subsequent libraries?

Upvotes: 1

Views: 631

Answers (1)

mhouglum
mhouglum

Reputation: 2593

You can run gsutil -D version and get lots of helpful debugging information about your gsutil installation, the Python version being used to run it, the config files being loaded, etc.

If you're running a gcloud installation of gsutil, you should see a line that looks like this in your output:

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

In that case, you should be able to specify the path to your preferred Python interpreter using the CLOUDSDK_GSUTIL_PYTHON environment variable, as mentioned in these docs.

But, if you're running a standalone installation gsutil (not part of a gcloud installation), you should make sure the Python version launched via the command /usr/bin/env python is the correct version -- this will be the first Python binary discoverable from the directories specified in your PATH environment variable, so you may have to edit and export your PATH appropriately.

Upvotes: 1

Related Questions