cannot import name 'external_account_authorized_user' from 'google.auth' - google-oauth

from pprint import pprint
from Goo_gle import Create_Service
CLIENT_SECRET_FILE = 'Client_Calendar.json'
API_NAME = 'calendar'
API_VERSION = 'v3'
SCOPES = ['https://www.googleapis.com/auth']
service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES)
Output:
Traceback (most recent call last): File "d:\Play with code\PROGRAMMINGS\Python\Artificial Inteligence\calen_dar.py", line 2, in <module>
from Goo_gle import Create_Service File "d:\Play with code\PROGRAMMINGS\Python\Artificial Inteligence\Goo_gle.py", line 5, in <module>
from google_auth_oauthlib.flow import Flow, InstalledAppFlow File "C:\Python\lib\site-packages\google_auth_oauthlib\__init__.py", line 21, in <module>
from .interactive import get_user_credentials File "C:\Python\lib\site-packages\google_auth_oauthlib\interactive.py", line 27, in <module>
import google_auth_oauthlib.flow File "C:\Python\lib\site-packages\google_auth_oauthlib\flow.py", line 69, in <module>
import google_auth_oauthlib.helpers File "C:\Python\lib\site-packages\google_auth_oauthlib\helpers.py", line 27, in <module>
from google.auth import external_account_authorized_user ImportError: cannot import name 'external_account_authorized_user' from 'google.auth' (C:\Python\lib\site-packages\google\auth\__init__.py)
I am not getting why this is happening.
This code was working from last 3 month but today after updating google libraries, this error came.. How to fix this?

Looks to be related to a recent change in the google-auth-library-python-oauth module:
https://github.com/googleapis/google-auth-library-python-oauthlib/pull/240/files#diff-63cdf7d9059947cf2f03b72a8137b8a1901de52f685705c251886d58a75b9381L8
Upgrading google-auth to 2.13.0 may fix it.

You will get that error when using google_auth_oauthlib as the latest version (0.6.0). Refer to this link: https://github.com/googleapis/google-auth-library-python-oauthlib/blob/v0.6.0/google_auth_oauthlib/helpers.py#L27
Try to downgrade google-auth-oauthlib lib by using this command:
pip install google-auth-oauthlib==0.4.6
or update your requirement.txt to add this line:
...
google-auth-oauthlib==0.4.6
...

Downgrade google-auth-oauthlib==0.6.0 (released yesterday) to 0.5.3 has solved my problem.
Thank's to #Samik

Related

Error when installing Pandas on Solaris 10

Currently we are on Python 2.7.17, and we are getting the following error:
sbdsvrwm261# ./pip install pandas
Traceback (most recent call last):
File "./pip", line 9, in <module>
load_entry_point('pip==8.1.2', 'console_scripts', 'pip')()
File "/opt/csw/lib/python2.7/site-packages/pkg_resources/__init__.py", line 565, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/opt/csw/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
return ep.load()
File "/opt/csw/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2291, in load
return self.resolve()
File "/opt/csw/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2297, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/opt/csw/lib/python2.7/site-packages/pip/__init__.py", line 16, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/opt/csw/lib/python2.7/site-packages/pip/vcs/subversion.py", line 9, in <module>
from pip.index import Link
File "/opt/csw/lib/python2.7/site-packages/pip/index.py", line 30, in <module>
from pip.wheel import Wheel, wheel_ext
File "/opt/csw/lib/python2.7/site-packages/pip/wheel.py", line 39, in <module>
from pip._vendor.distlib.scripts import ScriptMaker
File "/opt/csw/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 14, in <module>
from .compat import sysconfig, detect_encoding, ZipFile
File "/opt/csw/lib/python2.7/site-packages/pip/_vendor/distlib/compat.py", line 31, in <module>
from urllib2 import (Request, urlopen, URLError, HTTPError,
ImportError: cannot import name HTTPSHandler
If you require further information from me, please let me know.
Thanks
Pandas officially supports Python ^3.5.3.
Have you tried using virtualenv or docker to get Python 3.*?

Receive error when I run an executable created after py2exe conversion

After running my setup.py file and attempt to run the newly created .exe file I receive an error log that says:
Traceback (most recent call last):
File "Healthy_temp.py", line 7, in <module>
File "pandas\__init__.pyc", line 42, in <module>
File "pandas\core\api.pyc", line 26, in <module>
File "pandas\core\groupby\__init__.pyc", line 1, in <module>
File "pandas\core\groupby\groupby.pyc", line 37, in <module>
File "pandas\core\frame.pyc", line 100, in <module>
File "pandas\core\series.pyc", line 4390, in <module>
File "pandas\core\generic.pyc", line 10138, in _add_series_or_dataframe_operations
File "pandas\core\window.pyc", line 14, in <module>
File "pandas\_libs\window.pyc", line 12, in <module>
File "pandas\_libs\window.pyc", line 10, in __load
File "pandas\_libs\skiplist.pxd", line 31, in initpandas._libs.window
ImportError: No module named skiplist
My setup.py file is here:
from distutils.core import setup
import py2exe
import matplotlib
from PyQt4 import QtCore, QtGui
from AboutDialog import Ui_Dialog
from matplotlibwidget import MatplotlibWidget
import sys
from os import walk
from os import getcwd
import pandas
import numpy
from glob import glob
from datetime import datetime
from math import isnan
import sip
# setup(windows=['Healthy_temp.py'])
setup(options={'py2exe': {'bundle_files': 3, 'compressed': True}}, windows=[
'Healthy_temp.py'], zipfile=None,
data_files=matplotlib.get_py2exe_datafiles())
What can I do to correct this problem?
Add 'pandas._libs.skiplist' to the "includes" option list.

ImportError: No module named 'matplotlib._cntr'

When I run
#!/usr/bin/env python
import matplotlib
import matplotlib.pyplot as plt
I get following error
Traceback (most recent call last):
File "/home/wayne/alphaWorldsPython/code/mapTest.py", line 12, in <module>
import matplotlib.pyplot as plt
File "/home/wayne/matplotlib/pyplot.py", line 32, in <module>
import matplotlib.colorbar
File "/home/wayne/matplotlib/colorbar.py", line 36, in <module>
import matplotlib.contour as contour
File "/home/wayne/matplotlib/contour.py", line 14, in <module>
import matplotlib._cntr as _cntr
ImportError: No module named 'matplotlib._cntr'
When I look in matplotlib indeed ._cntr is not present.
I have tried reinstalling and updating. No change.
._cntr was a private module and it was removed from matplotlib. you can install this to still have the ._cntr in your matplotlib
https://github.com/matplotlib/legacycontour

python urllib error - AttributeError: 'module' object has no attribute 'request'

I am trying out a tutorial code which fetches the html code form a website and prints it. I'm using python 3.4.0 on ubuntu. The code:
import urllib.request
page = urllib.request.urlopen("http://www.brainjar.com/java/host/test.html")
text = page.read().decode("utf8")
print(text)
I saw previous solutions and tried them, I also tried importing only urllib but it still doesn't work. The error message displayed is as shown:
Traceback (most recent call last):
File "string.py", line 1, in <module>
import urllib.request
File "/usr/lib/python3.4/urllib/request.py", line 88, in <module>
import http.client
File "/usr/lib/python3.4/http/client.py", line 69, in <module>
import email.parser
File "/usr/lib/python3.4/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/usr/lib/python3.4/email/feedparser.py", line 27, in <module>
from email import message
File "/usr/lib/python3.4/email/message.py", line 15, in <module>
from email import utils
File "/usr/lib/python3.4/email/utils.py", line 40, in <module>
from email.charset import Charset
File "/usr/lib/python3.4/email/charset.py", line 15, in <module>
import email.quoprimime
File "/usr/lib/python3.4/email/quoprimime.py", line 44, in <module>
from string import ascii_letters, digits, hexdigits
File "/media/saiwal/D89602199601F930/Documents/Copy/codes/python/headfirst/string.py", line 2, in <module>
page = urllib.request.urlopen("http://www.brainjar.com/java/host/test.html")
AttributeError: 'module' object has no attribute 'request'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module>
from urllib.request import urlopen
File "/usr/lib/python3.4/urllib/request.py", line 88, in <module>
import http.client
File "/usr/lib/python3.4/http/client.py", line 69, in <module>
import email.parser
File "/usr/lib/python3.4/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/usr/lib/python3.4/email/feedparser.py", line 27, in <module>
from email import message
File "/usr/lib/python3.4/email/message.py", line 15, in <module>
from email import utils
File "/usr/lib/python3.4/email/utils.py", line 40, in <module>
from email.charset import Charset
File "/usr/lib/python3.4/email/charset.py", line 15, in <module>
import email.quoprimime
File "/usr/lib/python3.4/email/quoprimime.py", line 44, in <module>
from string import ascii_letters, digits, hexdigits
File "/media/saiwal/D89602199601F930/Documents/Copy/codes/python/headfirst/string.py", line 2, in <module>
page = urllib.request.urlopen("http://www.brainjar.com/java/host/test.html")
AttributeError: 'module' object has no attribute 'request'
Original exception was:
Traceback (most recent call last):
File "string.py", line 1, in <module>
import urllib.request
File "/usr/lib/python3.4/urllib/request.py", line 88, in <module>
import http.client
File "/usr/lib/python3.4/http/client.py", line 69, in <module>
import email.parser
File "/usr/lib/python3.4/email/parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "/usr/lib/python3.4/email/feedparser.py", line 27, in <module>
from email import message
File "/usr/lib/python3.4/email/message.py", line 15, in <module>
from email import utils
File "/usr/lib/python3.4/email/utils.py", line 40, in <module>
from email.charset import Charset
File "/usr/lib/python3.4/email/charset.py", line 15, in <module>
import email.quoprimime
File "/usr/lib/python3.4/email/quoprimime.py", line 44, in <module>
from string import ascii_letters, digits, hexdigits
File "/media/saiwal/D89602199601F930/Documents/Copy/codes/python/headfirst/string.py", line 2, in <module>
page = urllib.request.urlopen("http://www.brainjar.com/java/host/test.html")
AttributeError: 'module' object has no attribute 'request'
This looks like a nasty coincidence.
TL;DR: Don’t name your script string.py.
So what’s happening here?
You’re trying to import urllib.request.
urllib.request tries to import http.client, which tries to import email.parser, which tries to import email.feedparser, which tries to import email.message, which tries to import email.utils, which tries to import email.charset, which tries to import email.quoprimime.
email.quoprimime tries to import string, expecting it to be the standard Python string module—but since the current working directory has priority over the standard Python library directories, it finds your string.py instead and tries to import that.
When importing your string.py, you try to import urllib.request. Since urllib.request is still being imported, you get back a skeleton urllib without a request attribute yet.
Because your imported string.py then fails because it can’t find the request attribute, the exception starts propagating back up.
But wait, there’s more! Since there was an error during an import, Ubuntu tries to be helpful by seeing if you’re missing a dpkg package. If so, it could say “hey, it looks like you’re missing this module; want to apt-get it?” So the mechanism for looking up the appropriate package is activated…
…but the module for looking up the appropriate package itself depends on urllib.request, so it tries to import it, and again fails…
In short, because you picked string.py as a file name, you overrode the standard string module, which broke a lot of other modules, and even broke the module that was supposed to be helpful when you were missing a module, causing a whole lot of havoc. Fortunately the solution is easy: rename your script.

cannot import matplotlib.pylab with matplotlib installed

I understand that there have been several questions asked on this topic, however, I didn't find them able to solve my problem.
I installed matplotlib on the maching under /python-path/site-packages, both library and python are 64bits,
so I could import matplotlib no problem, but when I tried to import matplotlib.pylab or pylab, it gives me the following error
Traceback (most recent call last):
File "shownet.py", line 40, in <module>
import matplotlib.pylab
File "/usr/lib64/python2.6/site-packages/matplotlib/pylab.py", line 247, in <module>
from matplotlib.pyplot import *
File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 78, in <module>
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 8, in <module>
import gtk; gdk = gtk.gdk
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
_init()
File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
_gtk.init_check()
Would anyone know why this is so?
Also this is on linux, and I built it using setup.py