Python 2.7.5 (default, Sep 12 2013, 12:43:04)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] 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/local/lib/python2.7/urllib.py", line 33, in <module>
from urlparse import urljoin as basejoin
File "/usr/local/lib/python2.7/urlparse.py", line 118, in <module>
from collections import namedtuple
File "/usr/local/lib/python2.7/collections.py", line 9, in <module>
from operator import itemgetter as _itemgetter, eq as _eq
ImportError: cannot import name itemgetter
當我運行import urllib
時會出現此問題。 Python版本是2.7。是Python的版本問題?有人能告訴我如何解決它嗎?非常感謝 !Python導入錯誤:無法導入名稱itemgetter
你的代碼中是否有一個名稱爲「operator」的模塊? – zengr
我只是運行python shell,而不是python代碼... – changzhi
您在當前目錄中是否有一個名爲'operator.py'或'operator.pyc'的文件? –