logpuzzle exercise in Google Python Class: url error: "unknown url type: 'https'"

807 views
Skip to first unread message

Paul Gauthier

unread,
Oct 2, 2013, 4:14:12 PM10/2/13
to python-g...@googlegroups.com
So, I made it through all the exercises in the Pyton class and was feeling pretty smug, then I tried the logpuzzle exercise and I kept getting a url error: unknown url type: 'https'. I tried the version of the program in the solution directory to make sure it wasn't my code and got the same error with the official version.

It seems to be coming from the call to urllib.urlretrieve(img_url, os.path.join(dest_dir, local_name)). I'm running Python V 2.4.3 on Windows 7.

The contents of one of the url's I'm trying to retrieve is:

   http://code.google.com/edu/languages/google-python-class/images/puzzle/a-baaa.jpg

When I enter this in a Firefox address bar it gets redirected to:

   https://developers.google.com/edu/python/images/puzzle/a-baaa.jpg

Does the error have something to do with the redirection to an https address?

Robert Mandić

unread,
Oct 2, 2013, 5:40:17 PM10/2/13
to python-g...@googlegroups.com
Works with 2.7 on windows:

/images/puzzle/a-baaa.jpg", "aaa.jpg")
('aaa.jpg', <httplib.HTTPMessage instance at 0x00000000026604C8>)


--
You received this message because you are subscribed to the Google Groups "Python GCU Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-gcu-for...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Lp, Robert

Paul Gauthier

unread,
Oct 3, 2013, 8:52:57 AM10/3/13
to python-g...@googlegroups.com
Okay. When I do that in the interpreter I get this:

>>> import urllib

>>> urllib.urlretrieve("http://code.google.com/edu/languages/google-python-class
/images/puzzle/a-baaa.jpg","aaa.jpg")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Python24\lib\urllib.py", line 89, in urlretrieve
    return _urlopener.retrieve(url, filename, reporthook, data)
  File "C:\Python24\lib\urllib.py", line 222, in retrieve
    fp = self.open(url, data)
  File "C:\Python24\lib\urllib.py", line 190, in open
    return getattr(self, name)(url)
  File "C:\Python24\lib\urllib.py", line 322, in open_http
    return self.http_error(url, fp, errcode, errmsg, headers)
  File "C:\Python24\lib\urllib.py", line 335, in http_error
    result = method(url, fp, errcode, errmsg, headers)
  File "C:\Python24\lib\urllib.py", line 612, in http_error_301
    return self.http_error_302(url, fp, errcode, errmsg, headers, data)
  File "C:\Python24\lib\urllib.py", line 593, in http_error_302
    data)
  File "C:\Python24\lib\urllib.py", line 608, in redirect_internal
    return self.open(newurl)
  File "C:\Python24\lib\urllib.py", line 187, in open
    return self.open_unknown(fullurl, data)
  File "C:\Python24\lib\urllib.py", line 199, in open_unknown
    raise IOError, ('url error', 'unknown url type', type)
IOError: [Errno url error] unknown url type: 'https'

Paul G.

Robert Mandić

unread,
Oct 3, 2013, 9:49:07 AM10/3/13
to python-g...@googlegroups.com
​Works on 2.4.3 Linux version:

$ python
Python 2.4.3 (#1, Jan  9 2013, 06:49:54)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-54)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
>>>
('aaa.jpg', <httplib.HTTPMessage instance at 0xb7d309ac>)
Reply all
Reply to author
Forward
0 new messages