user904976
user904976

Reputation:

Importing urllib2 fails in python 2.7

When I try importing urllib2 , i get the following error

import urllib2
File "/usr/lib/python2.7/urllib2.py", line 94, in <module>
import httplib
File "/usr/lib/python2.7/httplib.py", line 79, in <module>
import mimetools
File "/usr/lib/python2.7/mimetools.py", line 6, in <module>
import tempfile
File "/usr/lib/python2.7/tempfile.py", line 34, in <module>
from random import Random as _Random
ImportError: cannot import name Random

i know that there is no module called Random, but i did check urllib2.py and there was code which imported Random.

I am using Python 2.7

Upvotes: 1

Views: 697

Answers (1)

C&#233;dric Julien
C&#233;dric Julien

Reputation: 80831

Maybe you have a random.py file or module on your pythonpath so python search in it to find random.Random (that exists on python2.7).

Upvotes: 3

Related Questions