博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python ImportError: cannot import name *
阅读量:7022 次
发布时间:2019-06-28

本文共 1184 字,大约阅读时间需要 3 分钟。

[root@company ~]# python /root/workspace/python/test/urllib.py

Traceback (most recent call last):
  File "/root/workspace/python/test/urllib.py", line 5, in <module>
    from urllib2 import urlopen
  File "/usr/lib/python2.6/urllib2.py", line 111, in <module>
    from urllib import (unwrap, unquote, splittype, splithost, quote,
  File "/root/workspace/python/test/urllib.py", line 5, in <module>
    from urllib2 import urlopen
ImportError: cannot import name urlopen

在学习的python的过程出现这个错误:

Actually, modules are searched in the list of directories given by the variable sys.path which is initialized from the directory containing the input script (or the current directory), PYTHONPATH and the installation- dependent default. This allows Python programs that know what they’re doing to modify or replace the module search path. Note that because the directory containing the script being run is on the search path, it is important that the script not have the same name as a standard module, or Python will attempt to load the script as a module when that module is imported.

最后发现我的测试目录下有个string.py的文件 导致python的一用错误。切记 要好好的阅读文档!!!

转载于:https://www.cnblogs.com/gongchang/archive/2012/12/28/2837430.html

你可能感兴趣的文章
警告:MySQL-server-5.5.46-1.linux2.6.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY...
查看>>
Spring 3整合Quartz 2实现定时任务三:动态暂停 恢复 修改和删除任务
查看>>
pipework let's assign static IP to docker container simple.
查看>>
gentoo prefix重生(llvm/clang)
查看>>
线程池的一点理解
查看>>
MacOS下shh,sftp,scp简单使用
查看>>
Android(支持kotlin) 新版Bintray-极简上传Library到JCenter,可上传自定义maven仓库
查看>>
css3毛玻璃
查看>>
vue生命周期
查看>>
Vue响应式原理源码浅析
查看>>
RxSwift (二) Working with Subjects
查看>>
2018年终总结与展望 | 掘金年度征文
查看>>
HTML常用标签
查看>>
UITesting常见问题收集
查看>>
AQS同步组件--Semaphore
查看>>
webpack系列之五module生成1
查看>>
关于Spring Cloud—环境变化
查看>>
吴颖二:12.13 晚评 美联储加息决议会否引起多头者“猛攻”
查看>>
Foundation中的类簇和Swizzle
查看>>
最新iOS面试真题大全
查看>>