解析 XML 文件时出现 IOError

IOError while parsing a XML file

我想使用 Python 和 XML 在我的 Autodesk Maya 场景中轻松创建对象。

当我尝试解析我的 XML 文件时,我得到了这个错误:

Error: IOError: file C:\Program Files\Autodesk\Maya2016\bin\python27.zip\xml\dom\expatbuilder.py line 922: 2 #

我写的代码是这个:

import maya.cmds as cmds
import xml.dom.minidom as xd

class readXML():
    def __init__(self):
        path = "mRigger/XML/arm.rig"
        print path

        xFile = xd.parse(path)
init = readXML()

只有在 Maya (Python 2.7) 中 运行 才会出现问题,而在 PyCharm

中 运行 则不会

尝试切换到绝对路径。您的 Maya 可能 运行 来自与 PyCharm 不同的工作目录。 IOError 2 通常意味着 'file not found'