简体   繁体   English

在Python 2.7中导入urllib或urllib 2失败,并出现ImportError:无法导入名称iskeyword

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

I can't import urllib or urllib2 on my Python 2.6 or Python 2.7 installs. 我无法在我的Python 2.6或Python 2.7安装中导入urllib或urllib2。

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 iskeyword

I can't seem to find an answer Googling "cannot import name iskeyword" either. 我似乎也找不到答案,谷歌搜索“也无法导入名称iskeyword”。

There must be some importing conflicts. 必须存在一些导入冲突。 Do you have any modules named keyword in you workspace? 您的工作区中是否有任何名为keyword模块? Try next: 尝试下一个:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导入&#39;urllib3.util&#39;在Python 2.7中失败了吗? - Import of 'urllib3.util' failing in Python 2.7? Python urllib3 错误 - 导入错误:无法导入名称 UnrewindableBodyError - Python urllib3 error - ImportError: cannot import name UnrewindableBodyError ImportError: 无法从 'urllib' (/usr/lib/python3.7/urllib/__init__.py) 导入名称 'quote' - ImportError: cannot import name 'quote' from 'urllib' (/usr/lib/python3.7/urllib/__init__.py) 无法在Python中导入urllib - Cannot import urllib in Python ImportError:无法从“urllib3.util.ssl_”导入名称“ssl” - ImportError: cannot import name 'ssl' from 'urllib3.util.ssl_' ImportError:无法从Windows的“ urllib.request”导入名称“ HTTPSHandler” - ImportError: cannot import name 'HTTPSHandler' from 'urllib.request' for windows 从 urllib3.util.ssl_ 导入(导入错误:无法导入名称 ssl - from urllib3.util.ssl_ import ( ImportError: cannot import name ssl import airflow - &gt; ImportError:无法导入名称版本(使用Python 2.7) - import airflow -> ImportError: cannot import name version (with Python 2.7) Windows Ubuntu Bash shell 上的 Python3.7 导入错误:无法从 &#39;urllib.request&#39; (/usr/lib/python3.7/urllib/request.py) 导入名称 &#39;HTTPSHandler&#39; - Python3.7 on Windows Ubuntu Bash shell ImportError: cannot import name 'HTTPSHandler' from 'urllib.request' (/usr/lib/python3.7/urllib/request.py) Python 2.7:Pytz:ImportError:无法导入名称时区 - Python 2.7 : Pytz : ImportError: cannot import name timezone
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM