0

I am following this tutorial and getting stuck with this error:

Traceback (most recent call last):
  File "/PycharmProjects/YouTube/Beer.py", line 2, in <module>
    import urllib.request
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 44
    `Parse list of key=value strings where keys are not duplicated.`

I am new to programming and to Python anyone have an idea what the issue is? Please be nice its my first time asking on Stack!

import random
import urllib.request
def download_web_image(url):
    name = random.randrange(1, 1000)
    full_name = str(name) + ".jpg"
    urllib.request.urlretrieve(url, full_name)
download_web_image(`https://avatars2.githubusercontent.com/u/8547538?s=460&u=8a4be84ff4870a332fe94c11fca02b432fb9f83e&v=4`)   

code

4
  • Welcome to SO! If you are new then maybe you have not heard of the python package called requests. It is going to be much easier to use than urllib. From your code above, however it looks like your url is not properly formatted using quotes, I think you have back ticks. " not ` Commented Mar 29, 2020 at 16:35
  • Is that the entire error message? The line beginning with download_web_image( seems to be somewhat broken, can you clarify what the code actually looks like? Commented Mar 30, 2020 at 0:18
  • added picture above Commented Mar 30, 2020 at 8:07
  • @JeffTilton What import do you recommend to get image. Commented Mar 30, 2020 at 12:44

1 Answer 1

1
import random
import urllib.request
def download_web_image(url):
    name = random.randrange(1, 1000)
    full_name = str(name) + ".jpg"
    urllib.request.urlretrieve(url, full_name)
download_web_image("https://avatars2.githubusercontent.com/u/8547538?s=460&u=8a4be84ff4870a332fe94c11fca02b432fb9f83e&v=4") 
Sign up to request clarification or add additional context in comments.

1 Comment

It has something to to with the request . Maybe i didnt import it correcttey? import urllib.request

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.