Nirmalya Roy
Nirmalya Roy

Reputation: 11

Why can't I open a URL in Python 3?

I am unable to open a URL in Python3. I am using an online editor named Repl.it for coding (https://repl.it/languages/python3)

Code:

import urllib.request
fp = urllib.request.urlopen("http://www.python.org")
mybytes = fp.read()
print(mybytes)

Error:

Traceback (most recent call last):
  File "python", line 2, in <module>

urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>

Upvotes: 1

Views: 724

Answers (1)

RomainL.
RomainL.

Reputation: 1014

I can't comment. I am able to replicate the problem on Repl.it. It seems to come from Repl.it. I do not have problem executing your code directly from python prompt In my computer.

Upvotes: 1

Related Questions