1

All I have is a 6 year old laptop, and I am trying to learn python, so maybe I can make some money in online marketing, which will lead to me having a proper unit where I can install an IDE, unlike now, where it keeps freezing since it cant hold itself together. I decided to work with sublime text because it is far more lighter and also has a built-in "build" function.

here is the code I am having difficulty running(trying to download a picture):

import random import urllib.request def download(url): name = random.randrange(1,1000) full_name = str(name) + ".jpg" urllib.request.urlretrieve(url, full_name) download("https://sites.psu.edu/siowfa16/files/2016/10/YeDYzSR-10apkm4.png") 

and here is the output:

Traceback (most recent call last): File "/home/kd/Desktop/pytest/python.py", line 2, in <module> import urllib.request ImportError: No module named request [Finished in 0.0s with exit code 1] 

i thought maybe sublime text is using the wrong version of python... here it was explained how to make sublime text use a different version of python:Python3.4 on Sublime Text 3 but its not working. should I just kill myself?

1 Answer 1

1

If your laptop is 6 years old, you are probably using python 2.7, which does not have module urllib.request. Either upgrade your python, or use module urllib2 (function urlopen()).

Sign up to request clarification or add additional context in comments.

Comments