Python 程序在eclipse能执行,但cmd里就报import的错了
报错如下:
Traceback (most recent call last):
File "flawfinder.py", line 2415, in flawfind() File "flawfinder.py", line 2408, in flawfind xml.flawcoverWriteAttrib(xml.flawcoverRead())
File "C:\Documents and Settings\Administrator\workspace\flawfinder_original\src\flawcover.py", line 23, in flawcoverRead root = etree.fromstring(xmlstr)
File "C:\Python27\lib\xml\etree\ElementTree.py", line 1301, in XML parser.feed(text)
File "C:\Python27\lib\xml\etree\ElementTree.py", line 1643, in feed self._raiseerror(v)
File "C:\Python27\lib\xml\etree\ElementTree.py", line 1507, in _raiseerror raise err xml.etree.ElementTree.ParseError: mismatched tag: line 71, column 2
我有两个文件 A.PY B.PY
在B.PY中调用
import xml.etree.ElementTree as etree
from xml.dom.minidom import Document
测试在eclipse下和cmd下都好使
而A.PY文件中运行的时候就在eclipse下好使,而在CMD下不好使
A.PY中调用了B.PY里面的类
试过的方法:
import sys
import os
curPath = os.path.abspath(os.path.dirname(__file__))
rootPath = os.path.split(curPath)[0]
sys.path.append(rootPath)