You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
OS type and version: ubuntu 16.04.6 LTS (4.15.0-1050-gcp)
Python version: 3.6.8
pip version: 3.6
google-api-python-client version: 1.7.1
Other dependency
fromapiclient.discoveryimportbuildSCOPES= ['https://www.googleapis.com/auth/analytics.readonly']
KEY_FILE_LOCATION=conf.KEY_FILE_LOCATIONcredentials=ServiceAccountCredentials.from_json_keyfile_name(
KEY_FILE_LOCATION, SCOPES)
# Build the service object.ifversion=='v4':
analytics=build('analyticsreporting', 'v4', credentials=credentials, cache_discovery=False)
elifversion=='v3':
analytics=build('analytics', 'v3', credentials=credentials, cache_discovery=False)
returnanalytics
PS. KEY_FILE_LOCATION is a json key generated from GCP
Stack trace
File "/home/dsu/ddt_dashboard/ddt_get_ga_report/lib/app.py", line 454, in get_report
analyticsV3 = initialize_analyticsreporting('v3')
File "/home/dsu/ddt_dashboard/ddt_get_ga_report/lib/app.py", line 117, in initialize_analyticsreporting
analytics = build('analytics', 'v3', credentials=credentials, cache_discovery=False)
File "/usr/local/lib/python3.6/dist-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.6/dist-packages/googleapiclient/discovery.py", line 300, in build
discovery_http.close()
AttributeError: 'Http' object has no attribute 'close'
The code works fine on my local machine (win10).
Not sure if it is about package dependency or something else.
C:\Python363\python.exe N:/matabares/PythonSnippets/demoGoogleDrive.py
Traceback (most recent call last):
File "N:/matabares/PythonSnippets/demoGoogleDrive.py", line 49, in
main()
File "N:/matabares/PythonSnippets/demoGoogleDrive.py", line 34, in main
service = build('drive', 'v3', credentials=creds)
File "C:\Python363\lib\site-packages\googleapiclient_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Python363\lib\site-packages\googleapiclient\discovery.py", line 300, in build
discovery_http.close()
AttributeError: 'Http' object has no attribute 'close'
Hi, as said, in the other ticket, did you try to upgrade to the last version of httplib2 as well? close() attribute belongs to http object from httplib2 library.
Maybe it was not existing in the version of the library you are currently using?
I'm seeing this issue as well with httplib2 0.19.0 and google-api-python-client 2.20.0
from google.oauth2 import service_account
from googleapiclient.discovery import build
def authenticate_service():
creds = service_account.Credentials.from_service_account_file(
SERVICE_ACCOUNT_FILE, scopes=SCOPES)
service = build('drive', 'v3', credentials=creds)
return service
here's the stack trace:
~/.local/lib/python3.8/site-packages/googleapiclient/_helpers.py in positional_wrapper(*args, **kwargs)
129 elif positional_parameters_enforcement == POSITIONAL_WARNING:
130 logger.warning(message)
--> 131 return wrapped(*args, **kwargs)
132
133 return positional_wrapper
~/.local/lib/python3.8/site-packages/googleapiclient/discovery.py in build(serviceName, version, http, discoveryServiceUrl, developerKey, model, requestBuilder, credentials, cache_discovery, cache, client_options, adc_cert_path, adc_key_path, num_retries, static_discovery)
313 # and can safely close it
314 if http is None:
--> 315 discovery_http.close()
316
317 if service is None:
AttributeError: 'Http' object has no attribute 'close'
Nevermind, I've got httplib2==0.14.0 installed in /usr/lib/python3/dist-packages that was actually being called despite having an updated httplib2 in ~/.local/lib/python3/site-packages
Traceback (most recent call last):
File "test_gcp.py", line 25, in
lservice = build('language', 'v1beta1', developerKey=APIKEY)
File "/usr/local/lib/python3.8/dist-packages/googleapiclient/_helpers.py", line 131, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/googleapiclient/discovery.py", line 321, in build
discovery_http.close()
AttributeError: 'Http' object has no attribute 'close'
i've upgrade to httplib2 0.20.4 but still have this problem ..
Activity
matabares commentedon Sep 26, 2020
I'm facing the same problem.
C:\Python363\python.exe N:/matabares/PythonSnippets/demoGoogleDrive.py
Traceback (most recent call last):
File "N:/matabares/PythonSnippets/demoGoogleDrive.py", line 49, in
main()
File "N:/matabares/PythonSnippets/demoGoogleDrive.py", line 34, in main
service = build('drive', 'v3', credentials=creds)
File "C:\Python363\lib\site-packages\googleapiclient_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Python363\lib\site-packages\googleapiclient\discovery.py", line 300, in build
discovery_http.close()
AttributeError: 'Http' object has no attribute 'close'
Process finished with exit code 1
jvalrog commentedon Sep 26, 2020
I've been developing a script for my company and today I also get that error. Yesterday it worked perfectly.
Mine is latest version: 1.12.2
Python3: 3.8.2
The error doesn't happen with version 1.12.1 (tried it using pipenv).
yohplala commentedon Sep 26, 2020
Hi, as said, in the other ticket, did you try to upgrade to the last version of
httplib2as well?close()attribute belongs tohttpobject fromhttplib2library.Maybe it was not existing in the version of the library you are currently using?
lpinilla commentedon Sep 26, 2020
Hi, I just want to add that I've just updated from python3.7 to python3.8 a few moments ago and a script I had stopped working for the newer version.
I'm using Ubuntu 20.04, let me know if you need more info
Edit: Forgot to add, I've run pip3 install httplib2 and it was already satisfied with version 0.14.0
yohplala commentedon Sep 26, 2020
@frankShih
Having a look at
httplib2changelog,close()method appeared in v0.15.0According your error report, you have version 0.12.0.
Please, upgrade 1st, then retry and report.
Thanks
lpinilla commentedon Sep 26, 2020
That fixed it! Thanks you for you time
yohplala commentedon Sep 26, 2020
1st time ever my feedback helps someone. Thanks to reply back ;) 👍
Feeling proud now ;)
jvalrog commentedon Sep 27, 2020
Fixed for me aswell.
google-api-python-client: 1.12.2
httplib2: 0.18.1
Arszilla commentedon Feb 18, 2021
I should note that this issue persists even with
httplib2version0.19.0:Update: I can confirm that this happens when using:
but not when using
austinweisgrau commentedon Sep 10, 2021
I'm seeing this issue as well with httplib2 0.19.0 and google-api-python-client 2.20.0
here's the stack trace:
austinweisgrau commentedon Sep 10, 2021
Nevermind, I've got httplib2==0.14.0 installed in /usr/lib/python3/dist-packages that was actually being called despite having an updated httplib2 in ~/.local/lib/python3/site-packages
hungchiehchi commentedon Mar 2, 2022
Traceback (most recent call last):
File "test_gcp.py", line 25, in
lservice = build('language', 'v1beta1', developerKey=APIKEY)
File "/usr/local/lib/python3.8/dist-packages/googleapiclient/_helpers.py", line 131, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/googleapiclient/discovery.py", line 321, in build
discovery_http.close()
AttributeError: 'Http' object has no attribute 'close'
i've upgrade to httplib2 0.20.4 but still have this problem ..
ben519 commentedon Dec 9, 2022
I needed to re-install
google-api-python-clientafter upgradinghttplib2for the error to go away.