繁体   English   中英

Python3:AttributeError:模块“ boto”没有属性“ plugin”

[英]Python3: AttributeError: module 'boto' has no attribute 'plugin'

我在Google Platform Compute Engine VM上运行一些代码,并且在导入Python boto库时收到错误消息。

如果我第一次运行“ import boto”,错误消息将是:

ModuleNotFoundError:没有名为“ urllib2”的模块

然后我再次运行它,出现了另一个错误消息:

AttributeError:模块“ boto”没有属性“ plugin”

我尝试安装google-compute-engine,但没有成功。 我也尝试过不同版本的Boto,但也失败了。

问题解决了。 不知道为什么,但是当您尝试在Google平台引擎上使用Boto时。 将存在一个文件/usr/share/google/boto/boto_plugins/compute_auth.py,您需要将行从'import urllib2'修改为'import urllib.request as urllib2'以适合Python3。 那一切都很好。

正如user10360186AttributeError中建议的那样 :模块'boto'没有属性'plugin'答案。 你必须执行

$ pip install google-compute-engine

并重新启动VM。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM