Search code examples
python-2.7maya

IOError while parsing a XML file


I wanted to use Python and XML to easily create objects in my Autodesk Maya Scene.

As soon as I try to parse my XML file, I get this Error :

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

The code that I wrote is this one :

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()

I only get the problem if I run it in Maya (Python 2.7) but not if I run it in PyCharm


Solution

  • Try switching to an absolute path. Your Maya may be running from a different working directory than PyCharm. an IOError 2 usually means 'file not found'