Module Problem


I using Linux OS. When i write this code

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)


It shows me this

Traceback (most recent call last):
File “/home/rupam/Desktop/”, line 2, in
import urllib.request
ImportError: No module named request
[Finished in 0.224s]

What should i do??


Maybe have a look at LINK1 or LINK2.

The above is a very wild guess… a guess made by a n00b.
There are other things to consider:

  • Which Atom package are you triggering the code with?
  • Which version(s) of Python do you have installed on your PC?
  • Which version of Python is the script running package using?
  • How sure are you that the library module is included in your own Python installation?
    (You might be using a subset or have a special environmental setup)


According to the error, you need to install the module before you can import it. However, when I look up the module, I find something interesting. If you’re using Python 2, that could be the source of the mismatch, and you should install Python 3.

What happens when you open the terminal and enter python /home/rupam/Desktop/ What do you get when you enter python --version?


Totally off-topic, just a general bit of advice: Please use descriptive words for your links! Posting the naked URL provides more information where a link might take me, a generic word does not provide anything. Do I want to click this link? Does it interest me? It’s easier when using a desktop browser with a status bar that display the actual target. But imagine someone using a mobile device where there are usually no such visual clues. I’m always interested in what people are posting, but this is an unnessary hurdle.