At first, I hoped I could find this problem anywhere on the internet, but I've searched a while and couldn't find anyone with a similar problem. When I try to run the googleapiclient
module, it kinda fails somewhere - and I'm not sure what's going wrong.
To test it, I've started to run the following file:
import googleapiclient
print('Step one!')
import googleapiclient.discovery
print('Step two!')
from googleapiclient.discovery import build
print('Yay! All steps complete!')
The first import goes well, as the first print statement is made successfully. However, after that, it all seems to go wrong;
Step one!
Traceback (most recent call last):
File "c:/Users/Bram/Documents/My Project/src/test.py", line 3, in <module>
import googleapiclient.discovery
File "C:\Users\Bram\AppData\Local\Programs\Python\Python36-32\lib\site-packages\googleapiclient\discovery.py", line 32, in <module>
from six.moves import http_client
File "C:\Users\Bram\AppData\Local\Programs\Python\Python36-32\lib\site-packages\six.py", line 92, in __get__
result = self._resolve()
File "C:\Users\Bram\AppData\Local\Programs\Python\Python36-32\lib\site-packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Users\Bram\AppData\Local\Programs\Python\Python36-32\lib\site-packages\six.py", line 82, in _import_module
__import__(name)
File "C:\Users\Bram\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 71, in <module>
import email.parser
File "C:\Users\Bram\AppData\Local\Programs\Python\Python36-32\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Users\Bram\AppData\Local\Programs\Python\Python36-32\lib\email\feedparser.py", line 27, in <module>
from email._policybase import compat32
File "C:\Users\Bram\AppData\Local\Programs\Python\Python36-32\lib\email\_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "C:\Users\Bram\AppData\Local\Programs\Python\Python36-32\lib\email\utils.py", line 33, in <module>
from email._parseaddr import quote
File "C:\Users\Bram\AppData\Local\Programs\Python\Python36-32\lib\email\_parseaddr.py", line 16, in <module>
import time, calendar
File "c:\Users\Bram\Documents\My Project\src\calendar.py", line 5, in <module>
from googleapiclient.discovery import build
ImportError: cannot import name 'build'
I've tried to force reinstall the module using pip
. I've installed any package that people suggested on similar threads where people had trouble with this package, (talking about apiclient
, httplib2
, oauth2client
and uritemplate
) and I'm really confused about this Traceback as it seems to refer to two different lines in my code.
What am I doing wrong?
You have caused a circular import. Your file is called calendar.py
, which hides the standard library module of the same name. As you can see in the traceback, _parseaddr.py
imports calendar
, expecting to find the stdlib module, but finds yours instead, and is now in a circle.
Rename your file to something else.