Can't find urllib2 or urlretrieve in Pythin 3.1.2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Kraft

    Can't find urllib2 or urlretrieve in Pythin 3.1.2

    I have installed Python 3.1.2 on a Windows 7 64-bit VM. When I attempt to import urllib2 it fails with the error:

    ImportError: No module named urllib2

    I tried using urllib.urlretri eve but that also doesn't exist:

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

    I tried re-installing Python and still get the above errors.

    This all works on my non-VM Windows 7 machine.

    Any ideas?

    Many thanks.
  • Kevin Kraft

    #2
    FYI: I worked around this by importing urllib.request and calling urllib.request. urlretrieve().

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #3
      Kevin,

      The following statement is from python.org and explains why you could not import urllib2:

      Note:
      The urllib2 module has been split across several modules in Python 3.0 named urllib.request and urllib.error. The 2to3 tool will automatically adapt imports when converting your sources to 3.0.

      Comment

      Working...