Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues about "AttributeError: module 'six.moves' has no attribute 'collections_abc'" #1039

Closed
kasumi515 opened this issue Sep 22, 2020 · 5 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@kasumi515
Copy link

I encountered this error message when I was trying to use google analytics API in python

AttributeError: module 'six.moves' has no attribute 'collections_abc'

Here is my python code:

from oauth2client.service_account import ServiceAccountCredentials
from apiclient.discovery import build
import httplib2

credentials = ServiceAccountCredentials.from_json_keyfile_name('client_secrets.json', ['https://www.googleapis.com/auth/analytics.readonly'])

http = credentials.authorize(httplib2.Http())
service = build('analytics', 'v4', http=http, discoveryServiceUrl=('https://analyticsreporting.googleapis.com/$discovery/rest'))

I noticed that someone might have filed the same issue couple days ago, but I still ran into this issue.
Here is the version info of google-api-python-client:

google-api-python-client-1.12.1 (by pip show google-api-python-client)
google-api-core-1.22.2
google-api-python-client-1.12.1
google-auth-1.21.2
google-auth-httplib2-0.0.4
httplib2-0.18.1
six-1.15.0

I am wondering if there is any revision I need to do to fix this issue?
Thank you in advance.

@busunkim96
Copy link
Contributor

collections was added to six in 1.13.0, so if you are using 1.1.50 it should be available. https://github.com/benjaminp/six/blob/c0be8815d13df45b6ae471c4c436cce8c192245d/CHANGES#L25-L36

Can you try in a new virtualenv?

python3 -m venv env
source env/bin/activate
python3 -m pip install ...
python3 -m name_of_script.py

In addition, oauth2client is no longer maintained so you should use google-auth.

from google.oauth2 import service_account

credentials = service_account.Credentials.from_service_account_file(
    '/path/to/key.json')

scoped_credentials = credentials.with_scopes(
    ['https://www.googleapis.com/auth/cloud-platform'])

@busunkim96 busunkim96 added the type: question Request for information or clarification. Not an issue. label Sep 22, 2020
@busunkim96 busunkim96 self-assigned this Sep 22, 2020
@kasumi515
Copy link
Author

@busunkim96
Thank you so much for your reply!
I tried to install the packages in a new virtualenv and it worked!
Here is the code I used for others' reference:

from google.oauth2 import service_account
from googleapiclient.discovery import build
 
credentials = service_account.Credentials.from_service_account_file('client_secrets.json')
scoped_credentials = credentials.with_scopes(['https://www.googleapis.com/auth/cloud-platform'])

#Create a service object
service = build('analytics', 'v3', credentials=scoped_credentials)

@afaghm
Copy link

afaghm commented Sep 23, 2020

I still have this problem. Six is updated to 1.15.0 and google api client is updated to 1.12.2. I have also tried installing packages in a new environment but to no avail. Is anyone able to help please?

@keepcool13
Copy link

keepcool13 commented Sep 25, 2020

I get the same error, but I'm using the Earth Engine Python API. I need it for for a plugin in a third-party software, so I don't think I can use a virtual environment. I filed the error in the project of the plugin gee-community/qgis-earthengine-plugin#67 because I first thought the plugin is the issue. Because it only occurs if I start the plugin, not when I call the same function in a standard Python console. But when I looked closer I realized that the bug actually comes from here. But it is pretty strange that it only occurs if the plugin uses the API.

@busunkim96
Copy link
Contributor

I've confirmed that setup.py is correctly requiring >=1.13.0. Please check where your version pins and bump to a sufficiently new version of six.

"six>=1.13.0,<2dev",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants