Brutal_JL
Brutal_JL

Reputation: 2847

Why I can't import urllib2? I already have new a python interpreter in preference

import urllib2

I can't import urllib2. I received this error:

Unresolved import: urllib2

They said that I should have a new python interpreter in the preference. But I've already done that. Please give me some clue about this.

Upvotes: 0

Views: 3562

Answers (2)

thefourtheye
thefourtheye

Reputation: 239433

In python3, you have to use urllib3. Documentation http://urllib3.readthedocs.org/en/latest/

import urllib3
http = urllib3.PoolManager()
response = http.request('GET', 'http://www.google.com')
print (response.data)

And there is no raw_input in python3. You have to use input function in python 3. Python 2's input is equivalent to eval(input()) in python 3

Upvotes: 3

Mark Tolonen
Mark Tolonen

Reputation: 177396

Python 3.x is not compatible with Python 2.x. Your Internet example is for 2.x, and 3.x does not have an urllib2 module.

Upvotes: 1

Related Questions