0

I am running some code on a Google Platform Compute Engine VM and I get an error when I imported Python boto library.

The first time if I run 'import boto', the error message would be:

ModuleNotFoundError: No module named 'urllib2'

Then I ran it again, a different error message came out:

AttributeError: module 'boto' has no attribute 'plugin'

I tried installing google-compute-engine but it didn't work. I also tried different versions of boto but failed as well.

Andrei Cusnir
  • 2,735
  • 1
  • 14
  • 21
XXin
  • 19
  • 3

2 Answers2

1

As it is suggested by user10360186 in AttributeError: module 'boto' has no attribute 'plugin' answer. You have to execute

$ pip install google-compute-engine

and restart the VM.

Andrei Cusnir
  • 2,735
  • 1
  • 14
  • 21
1

Problem solved. Not sure why but when you try to use boto on a google platform engine. There will be a file /usr/share/google/boto/boto_plugins/compute_auth.py, you need to modify the line from 'import urllib2' to 'import urllib.request as urllib2' to fit Python3. Then it is all good.

XXin
  • 19
  • 3