Difference between revisions of "GSUTIL command error with Python module"
(→Solution) |
(→Solution) |
||
| Line 43: | Line 43: | ||
</p> | </p> | ||
It should look like below:<br> | It should look like below:<br> | ||
| − | [[file:compute_auth_python.png| | + | [[file:compute_auth_python.png|600px]] |
Revision as of 20:21, 10 August 2022
Problem
Error occur during execute command :
sudo gsutil -m mv /home/user/appl/SG-infinite-20*.zip gs://sg-storage
Error message:
Traceback (most recent call last):
File "/usr/lib/google-cloud-sdk/platform/gsutil/gsutil", line 21, in <module>
gsutil.RunMain()
File "/usr/lib/google-cloud-sdk/platform/gsutil/gsutil.py", line 150, in RunMain
import gslib.__main__
File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/__main__.py", line 53, in <module>
import boto
File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/vendored/boto/boto/__init__.py", line 1216, in <module>
boto.plugin.load_plugins(config)
File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/vendored/boto/boto/plugin.py", line 93, in load_plugins
_import_module(file)
File "/usr/lib/google-cloud-sdk/platform/gsutil/gslib/vendored/boto/boto/plugin.py", line 75, in _import_module
return imp.load_module(name, file, filename, data)
File "/usr/lib/google-cloud-sdk/platform/bundledpythonunix/lib/python3.9/imp.py", line 234, in load_module
return load_source(name, filename, file)
File "/usr/lib/google-cloud-sdk/platform/bundledpythonunix/lib/python3.9/imp.py", line 171, in load_source
module = _load(spec)
File "/usr/share/google/boto/boto_plugins/compute_auth.py", line 18, in <module>
import urllib2
ModuleNotFoundError: No module named 'urllib2'
Solution
This error could happen after upgrade Google Cloud SDK to the latest version. You might have multiple version of python then run following command to use the latest version:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
then you will receive below information:
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode
Then update the file compute_auth.py, change the line import urllib2 to import urllib.request as urllib2.