[Python-porting] ImportError: No module named urllib

Chris Jerdonek chris.jerdonek at gmail.com
Fri May 23 23:17:57 CEST 2014


On Fri, May 23, 2014 at 1:06 PM, Ned Deily <nad at acm.org> wrote:
> In article
> <CAL0kPAUbyS6u5J0kt2QWZhyxwZ7RVbaj0DffZ8OcotMSOs8Dow at mail.gmail.com>,
>  Lennart Regebro <regebro at gmail.com>
>  wrote:
>> That's very strange. You are running Python 2.7, but it says that it
>> can't find urllib.
>
> It's easy to overlook: the relevant part of the traceback is earlier:
>
>> > line 34, in <module>
>> >     from six.moves.urllib import parse
>> > ImportError: No module named urllib
>
> So it's not the standard library urllib module, rather part of the six
> compatibility lib.  Dunno, I was just able to install python-novo using
> pip with Python 2.7.6 on OS X 10.9 and the nova command seemed to work.
> And, in particular, from within the Python interactive interpreter,
> typing:
>
> from six.moves.urllib import parse
>
> worked.  Perhaps you should check permissions on the the site-packages
> files?

It's also possible that the error message is misleading and the
underlying error being swallowed if six is doing something fancy.  For
example, I seem to remember a bug in the unittest module where, when
loading tests (to use the example above), an error processing the
parse module would show up as an error like the above ("ImportError:
No module named urllib").

--Chris


More information about the Python-porting mailing list