2

I extremely new to python and practicing Loading a dataset from a url.

When running the following code:

In [1]: myUrl = "http://aima.cs.berkeley.edu/data/iris.csv"
In [2]: urlRequest = urllib.request.Request(myUrl)

I get this error:

File "", line 1, in urlRequest = urllib.request.Request(myUrl)

AttributeError: 'module' object has no attribute 'request'

1) I tried researching this error and attempted to use import urllib3 again and it imported fine. However when attempting the request I get that error...

2) I attempted to get "help" help("urllib3") in python 3.6.0 and got:

No Python documentation found for 'urllib3'. Use help() to get the interactive help utility. Use help(str) for help on the str class.

3) I searched Stackoverflow and saw a similar question; tried the suggestions and was not able to move past that line of code...

Am I doing something wrong here?

Thanks in advance for your time

1 Answer 1

2

From what I see "request" is not a package, meaning that you can't directly import classes from it.

try :

from urllib.request import Request
myUrl = "http://aima.cs.berkeley.edu/data/iris.csv"
urlRequest = Request(myUrl)
Sign up to request clarification or add additional context in comments.

2 Comments

You can also use "import urllib.request" and then use "urllib.request.Request" but it is more concise like this
Happy to hear that ! Please consider accepting it so it helps referencing for other users having the same problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.