question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'Http' object has no attribute 'close'

See original GitHub issue

Environment details

  • 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 image

from apiclient.discovery import build
SCOPES = ['https://www.googleapis.com/auth/analytics.readonly']
KEY_FILE_LOCATION = conf.KEY_FILE_LOCATION

credentials = ServiceAccountCredentials.from_json_keyfile_name(
        KEY_FILE_LOCATION, SCOPES)

# Build the service object.
if version == 'v4':
    analytics = build('analyticsreporting', 'v4', credentials=credentials, cache_discovery=False)
elif version == 'v3':
    analytics = build('analytics', 'v3', credentials=credentials, cache_discovery=False)
return analytics

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.

Any suggestions would be appreciated, thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:13

github_iconTop GitHub Comments

3reactions
yohplalacommented, Sep 26, 2020

@frankShih

Having a look at httplib2 changelog, close() method appeared in v0.15.0

According your error report, you have version 0.12.0.

Please, upgrade 1st, then retry and report. Thanks

2reactions
jvalrogcommented, Sep 27, 2020

Fixed for me aswell.

google-api-python-client: 1.12.2 httplib2: 0.18.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python AttributeError: NoneType object has no attribute 'close'
I am learning python and I wrote a script that copies the content of one text file to another. Here is my code....
Read more >
AttributeError: 'BlobMedia' object has no attribute 'status'
I am making an HTTP request from client code and I want to ensure the status of the response is a successful one....
Read more >
B2G "AttributeError: 'NoneType' object has no attribute 'close ...
Broken out from bug 1009316. example: https://tbpl.mozilla.org/php/getParsedLog.php?id=39918406&tree=Try { 17:53:40 INFO - TEST-START ...
Read more >
http.client — HTTP protocol client — Python 3.11.1 ...
Source code: Lib/http/client.py This module defines classes that implement the client side of ... indicating that the remote end has closed the connection....
Read more >
Request and response objects - Django documentation
The path_info attribute always contains the path info portion of the path, no matter ... A dictionary-like object containing all given HTTP POST...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found