0

I am trying to import the modules necessary to access the google calendar APIs, but the program errors on the line: 'from googleapiclient import discovery' and comes up with this error message

Traceback (most recent call last):
  File "C:/Users/Jake/Documents/Programming/Python/google apis/calendar/calendar.py", line 3, in <module>
from apiclient import discovery
File "C:\Python36\lib\site-packages\apiclient\__init__.py", line 19, in <module>
from googleapiclient import discovery
File "C:\Python36\lib\site-packages\googleapiclient\discovery.py", line 32, in <module>
from six.moves import http_client
File "C:\Python36\lib\site-packages\six.py", line 92, in __get__
result = self._resolve()
File "C:\Python36\lib\site-packages\six.py", line 115, in _resolve
return _import_module(self.mod)
File "C:\Python36\lib\site-packages\six.py", line 82, in _import_module
__import__(name)
File "C:\Python36\lib\http\client.py", line 71, in <module>
import email.parser
File "C:\Python36\lib\email\parser.py", line 12, in <module>
from email.feedparser import FeedParser, BytesFeedParser
File "C:\Python36\lib\email\feedparser.py", line 27, in <module>
from email._policybase import compat32
File "C:\Python36\lib\email\_policybase.py", line 9, in <module>
from email.utils import _has_surrogates
File "C:\Python36\lib\email\utils.py", line 33, in <module>
from email._parseaddr import quote
File "C:\Python36\lib\email\_parseaddr.py", line 16, in <module>
import time, calendar
File "C:/Users/Jake/Documents/Programming/Python/google apis/calendar\calendar.py", line 3, in <module>
from apiclient import discovery
ImportError: cannot import name 'discovery'

It only does this in the directory I currently have the python file in. I have a few other programs that use the same boilerplate code which don't show this error. Any ideas?

Thanks

strava
  • 765
  • 6
  • 14
  • 4
    Possible duplicate of [Importing installed package from script raises "AttributeError: module has no attribute" or "ImportError: cannot import name"](https://stackoverflow.com/questions/36250353/importing-installed-package-from-script-raises-attributeerror-module-has-no-at) – vaultah Sep 17 '17 at 14:35
  • `import calendar` in `_parseaddr.py` imports your own file. – vaultah Sep 17 '17 at 14:37
  • I think I understand, is it simply that my python file shares the name of a module in the python36\lib directory? – strava Sep 17 '17 at 14:52
  • Yes, in this case your script takes precedence over the module from standard library. You should be able to close your question as duplicate by clicking the ["That solved my problem!" button](https://meta.stackoverflow.com/q/300364/2301450) – vaultah Sep 17 '17 at 15:08
  • Please don't edit your question with "SOLVED" and other fluff. Either accepted answers or eventually duplicate closure banners will carry whatever meta-data needs conveying. – Andras Deak -- Слава Україні Sep 18 '17 at 16:14

0 Answers0