开发者

Import urllib or urllib 2 in Python 2.7 failing with ImportError: cannot import name iskeyword [duplicate]

This question already has answers here: Importing installed package from script with the same name raises "AttributeError: module has no attribute" or an ImportError or NameError (2 answers) Closed 1 year ago.

I can't import urllib or urllib2 on my Python 2.6 or Python 2.7 installs.

Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) 
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import urllib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/urllib.py", line 30, in <module>
    from urlparse import urljoin as basejoin
  File "/usr/lib/python2.7/urlparse.py", line 110, in <module>
    from collections import namedtuple
  File "/usr/lib/python2.7/collections.py", line 10, in <module>
    from keyword import iskeyword as _iskeyword
ImportError: cannot import name iskey开发者_如何学Pythonword

I can't seem to find an answer Googling "cannot import name iskeyword" either.


There must be some importing conflicts. Do you have any modules named keyword in you workspace? Try next:

>>> import keyword
>>> dir(keyword)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜