This is my code :
from oauth2client.service_account import ServiceAccountCredentials
from apiclient import discovery
from httplib2 import Http
key_path = os.environ["GOOGLE_APPLICATION_CREDENTIALS"]
# define scope
SCOPE = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
# define store
credentials = ServiceAccountCredentials.from_json_keyfile_name(key_path, SCOPE)
# define API service
http = credentials.authorize(Http())
drive = discovery.build('drive', 'v3', http=http) # ERROR HERE
I'm hitting error at drive
with error message :
AttributeError: module 'time' has no attribute 'clock'
I'm using Python 3.8. Please help. I can upload error message if needed.
Error log :
File "/Users/mydirectory/Documents/my-project/config.py", line 36, in <module>
drive = discovery.build('drive', 'v3', http=http)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/googleapiclient/discovery.py", line 270, in build
content = _retrieve_discovery_doc(
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/googleapiclient/discovery.py", line 376, in _retrieve_discovery_doc
resp, content = req.execute(num_retries=num_retries)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/googleapiclient/http.py", line 900, in execute
resp, content = _retry_request(
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/googleapiclient/http.py", line 177, in _retry_request
resp, content = http.request(uri, method, *args, **kwargs)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/oauth2client/transport.py", line 159, in new_request
credentials._refresh(orig_request_method)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/oauth2client/client.py", line 749, in _refresh
self._do_refresh_request(http)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/oauth2client/client.py", line 774, in _do_refresh_request
body = self._generate_refresh_request_body()
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/oauth2client/client.py", line 1484, in _generate_refresh_request_body
assertion = self._generate_assertion()
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/oauth2client/service_account.py", line 384, in _generate_assertion
return crypt.make_signed_jwt(self._signer, payload,
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/oauth2client/crypt.py", line 97, in make_signed_jwt
signature = signer.sign(signing_input)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/oauth2client/_pycrypto_crypt.py", line 99, in sign
return PKCS1_v1_5.new(self._key).sign(SHA256.new(message))
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/Crypto/Signature/PKCS1_v1_5.py", line 112, in sign
m = self._key.decrypt(em)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/Crypto/PublicKey/RSA.py", line 174, in decrypt
return pubkey.pubkey.decrypt(self, ciphertext)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/Crypto/PublicKey/pubkey.py", line 93, in decrypt
plaintext=self._decrypt(ciphertext)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/Crypto/PublicKey/RSA.py", line 235, in _decrypt
r = getRandomRange(1, self.key.n-1, randfunc=self._randfunc)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/Crypto/Util/number.py", line 123, in getRandomRange
value = getRandomInteger(bits, randfunc)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/Crypto/Util/number.py", line 104, in getRandomInteger
S = randfunc(N>>3)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 202, in read
return self._singleton.read(bytes)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 178, in read
return _UserFriendlyRNG.read(self, bytes)
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 129, in read
self._ec.collect()
File "/Users/mydirectory/Documents/my-project/venv/lib/python3.8/site-packages/Crypto/Random/_UserFriendlyRNG.py", line 77, in collect
t = time.clock()
AttributeError: module 'time' has no attribute 'clock'
question from:
https://stackoverflow.com/questions/66056550/google-api-attributeerror-module-time-has-no-attribute-clock