2
아주 이상한 가져옵니다파이썬 모듈은 나에 대한 오류
# 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 [[email protected] 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 #
요약 : 나는 다른 경로에서 같은 파이썬 모듈을 가져올 수 없습니다. 아이디어가 있으십니까? 0_o
P. SELINUX = 비활성화 됨
>>> 수입 DNS >>> DNS .__ FILE__ '/usr/local/lib/python2.6/site-packages/dns/__init__.pyc' >>> 절대 경로 – ololo
빙고 다음 'site-packages'의'dns' 서브 디렉토리는 여러분이 필요로하는 모든 것을 가지고 있습니다. 반면에'dev/dns'의'dns' 서브 디렉토리는 ('resolver' 모듈이 없거나 지시 할'.pth' 파일이 없습니다 그것, 또는 그 ilk의 무엇인가). –
사실, 패키지 대신에 가져온'dns.py' 파일의 작업 디렉토리에있는 것이 충분히 설명되어 있습니다. import가 현재 디렉토리에서 해결되기를 원하지 않는다면 (파이썬이 정상적으로 동작 할 때), import하기 전에'sys.path'를 수정할 수 있습니다. –