Aveo Renzhio
Aveo Renzhio

Reputation: 21

Python version 2.7 does not have module http.client

I have installed python version 3.7 and i'm trying to run a python program by importing http.client module but IDE is showing a warning that the python version 2.7 does not have module http.client

import http.client

conn = http.client.HTTPConnection("www,google,com")

payload = "<atom:entry xmlns:atom=\"http://www.w3.org/2005/Atom\"\r\n    xmlns:gd=\"http://schemas.google.com/g/2005\">\r\n  <atom:category scheme=\"http://schemas.google.com/g/2005#kind\"\r\n    term=\"http://schemas.google.com/contact/2008#contact\"/>\r\n  <gd:name>\r\n     <gd:givenName>Elizabeth</gd:givenName>\r\n     <gd:familyName>Bennet</gd:familyName>\r\n     <gd:fullName>Elizabeth Bennet</gd:fullName>\r\n  </gd:name>\r\n  <atom:content type=\"text\">Notes</atom:content>\r\n  <gd:email rel=\"http://schemas.google.com/g/2005#work\"\r\n    primary=\"true\"\r\n    address=\"[email protected]\" displayName=\"E. Bennet\"/>\r\n  <gd:email rel=\"http://schemas.google.com/g/2005#home\"\r\n    address=\"[email protected]\"/>\r\n  <gd:phoneNumber rel=\"http://schemas.google.com/g/2005#work\"\r\n    primary=\"true\">\r\n    (206)555-1212\r\n  </gd:phoneNumber>\r\n  <gd:phoneNumber rel=\"http://schemas.google.com/g/2005#home\">\r\n    (206)555-1213\r\n  </gd:phoneNumber>\r\n</atom:entry>"

headers = {
'Content-Type': "text/xml",
'Authorization': "Bearer ya29.GlvfBn2_hfj3pGo2ynUXORjaXed6j4GpoogZzcoQE6JLWHFlrG84I6FDjbbWRRjniM4XHAQiYddbiUUpSVDMLDNIzrasJUu9Kt59gZzfrv6XcLok6iATmP5jSwXk",
'cache-control': "no-cache",
'Postman-Token': "5b55e4ca-2c6e-4e87-8615-e76c659d4f24"
}

conn.request("POST", "m8,feeds,contacts,default,full", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

Upvotes: 2

Views: 4437

Answers (1)

Ned Batchelder
Ned Batchelder

Reputation: 375854

It was called httplib in Python 2.

Are you sure you want to be running Python 2? It's almost at end-of-life.

Upvotes: 2

Related Questions