Python模块导入错误
这让我觉得很奇怪:
# uname -a Linux localhost.localdomain 2.6.18-194.3.1.el5 #1 SMP Thu May 13 13:09:10 EDT 2010 i686 i686 i386 GNU/Linux # pwd /root # python Python 2.6.5 (r265:79063, Apr 11 2010, 22:34:44) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import dns >>> [3]+ Stopped python # cd /home/user/dev/dns [root@localhost dns]# python Python 2.6.5 (r265:79063, Apr 11 2010, 22:34:44) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import dns Traceback (most recent call last): File "", line 1, in File "dns.py", line 1, in import dns.resolver ImportError: No module named resolver >>> [4]+ Stopped python #
总结一下:我无法从不同的路径导入同一个Python模块。有没有什么想法?0_o
附注:SELINUX=禁用
1 个回答
4
在第一个例子中,dns.__file__
是什么呢?我怀疑它并不是来自你第二次进入的那个目录(当你启动Python时,当前目录会放在sys.path
的最前面),而是来自一个包含那个重要的resolver
模块的包,而第二个例子似乎缺少这个模块。