Error import No module name urllib2

0 votes

I'm trying to import urllib2 but it execute some error as:

import No module name urllib2

Here's my code:

import urllib2.request

response = urllib2.urlopen("http://www.google.com")
html = response.read()
print(html)

How can i resolve this error??

May 5, 2020 in Python by kartik
• 37,510 points
2,636 views

1 answer to this question.

0 votes

Hii,

You have to install the modules like bs4, as it's not part of the default, standard Python pack. 

This worked for me in python3:

import urllib.request
htmlfile = urllib.request.urlopen("http://google.com")
htmltext = htmlfile.read()
print(htmltext)

Hope this works!!
Thank You!!

answered May 5, 2020 by Niroj
• 82,880 points

Related Questions In Python

0 votes
2 answers

Python error " import requests ImportError: No module named requests"

Hello, Open Cmd or Powershell as Admin. type pip ...READ MORE

answered Nov 28, 2020 in Python by Rohan
• 200 points
16,917 views
0 votes
1 answer
0 votes
1 answer

Python Requests module - Import Error: No module named requests

Run with Python 3 from the command ...READ MORE

answered Sep 11, 2020 in Python by Malik Brahimi
19,888 views
0 votes
1 answer

No module name scikitplot

To overcome this issue, you need to ...READ MORE

answered Mar 9, 2019 in Python by Siri
4,589 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,059 views
0 votes
1 answer
0 votes
1 answer

Import error: No module name urllib2

As stated in the urllib2 documentation: The urllib2 module has been split ...READ MORE

answered May 11, 2020 in Python by Niroj
• 82,880 points
12,225 views
0 votes
1 answer

Import Error: No module named numpy?

Hello, I had numpy installed on the same ...READ MORE

answered Apr 14, 2020 in Python by Niroj
• 82,880 points
12,379 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP