今天在写一个小脚本时碰到了一个异常错误, 出现一些莫名其妙的错误, 忽然间所有程序都无法运行.
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "product_quality.py", line 4, in <module>
import urllib2, urllib, cookielib
File "/usr/lib/python2.6/urllib2.py", line 94, in <module>
import httplib
File "/usr/lib/python2.6/httplib.py", line 78, in <module>
import mimetools
File "/usr/lib/python2.6/mimetools.py", line 4, in <module>
import os
File "/usr/lib/python2.6/os.py", line 49, in <module>
import posixpath as path
File "/usr/lib/python2.6/posixpath.py", line 14, in <module>
import stat
File "/home/guodongdong/tools/stat.py", line 2, in <module>
from lxml.html.soupparser import fromstring
File "/usr/lib/python2.6/dist-packages/lxml/html/__init__.py", line 12, in <module>
from lxml import etree
File "lxml.etree.pyx", line 30, in init lxml.etree (src/lxml/lxml.etree.c:140754)
ImportError: No module named path
搜索了半天没有结果后, 还是仔细的研究了traceback, 最后发现 File "/usr/lib/python2.6/posixpath.py", line 14, in <module>
import stat, 我当前目录下有一个stat.py脚本, import时就无法识别了.
看来系统内部包在查找的时候也不是使用命名空间的, 这样我们以后的module命名时就不要和系统包相同了.