gcloud版本306.0.0导致“没有名为'urllib2'的模块".错误 [英] gcloud version 306.0.0 causing "No module named 'urllib2'" errors

查看:116
本文介绍了gcloud版本306.0.0导致“没有名为'urllib2'的模块".错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

gcloud从290.0.1版本更新到306.0.0版本后,运行gsutil cp命令时出现错误:

After updating gcloud from version 290.0.1 to version 306.0.0, I'm getting an error when I run a gsutil cp command:

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 122, 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/python3.6/imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "/usr/lib/python3.6/imp.py", line 172, 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'

按照 https://cloud.google上的降级说明进行操作. com/sdk/docs/downloads-apt-get#downgrading_cloud_sdk_versions 暂时解决了该问题:

Following the downgrade instructions at https://cloud.google.com/sdk/docs/downloads-apt-get#downgrading_cloud_sdk_versions temporarily fixes the issue:

sudo apt-get update && sudo apt-get install google-cloud-sdk=290.0.1-0

但是我想知道如何使它与最新版本一起使用.

But I'd like to know how to get this working with the latest version.

推荐答案

我已经安装了版本306.0.0,并且运行了gcloud cp命令,但是我没有遇到这个问题.因此,检查错误原因ModuleNotFoundError: No module named 'urllib2',似乎它们总是与无法正常工作的Python库有关-您可以在这两个示例中进行检查此处.

I have installed the version 306.0.0 and I ran a gcloud cp command, but I didn't face the issue. For this reason, checking for causes for the error ModuleNotFoundError: No module named 'urllib2', it seems that they are always related to a Python library that isn't working correctly - as you can check in this two examples here and here.

但是,在进一步的搜索中,此插件通常在Compute Engine和带有Python的VM的启动脚本中使用,更具体地与文件compute_auth.py有关-在消息中似乎与错误有关-当您可以检查更多信息此处有关此文件.

However, in further searches, this plugin usually is used within Compute Engine and startup scripts to VMs with Python, more specific relating to the file compute_auth.py - which in the message seems to be related to the error - and as you can check for more information here about this file.

考虑到这一点,新版Cloud SDK带来了一些更新到可能导致错误的Compute Engine.如果确实在您的应用程序中使用Python,则可以尝试使用这种情况下的解决方案

Considering that, the new version of Cloud SDK bring some updates to Compute Engine that could be causing the error. In case you are indeed, using Python within your applications, I would give it a try the solution from this case here, that would be to update the file compute_auth.py, changing the line import urllib2 toimport urllib.request as urllib2.

如果无法解决此问题,请在将是最好的选择,以进行进一步的调查.

In case this doesn't fix, raising a bug within Google's Issue Tracker will be the best option, for a further investigation.

这篇关于gcloud版本306.0.0导致“没有名为'urllib2'的模块".错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆