Link to home
Start Free TrialLog in
Avatar of mikezang
mikezang

asked on

What does error "AttributeError: 'NoneType' object has no attribute 'parse'" mean?

I use some code as below:
from xml.dom import minidom
xmldoc1 = minidom.parse('my.xml')

When I run it, I got error as below:
load_module xml
load_module xml.dom
load_module xml.dom.minidom
load_module xml.dom.expatbuilder
xml.dom.expatbuilder import failed
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "<string>", line 52, in load_module
  File "CvEventInterface", line 13, in ?
  File "<string>", line 52, in load_module
  File "CvEventManager", line 12, in ?
  File "<string>", line 52, in load_module
  File "CvScreensInterface", line 16, in ?
  File "<string>", line 52, in load_module
  File "CvOptionsScreen", line 17, in ?
  File "C:\Python24\lib\xml\dom\minidom.py", line 1915, in parse
    return expatbuilder.parse(file)
AttributeError: 'NoneType' object has no attribute 'parse'

Does anyone help me?
ASKER CERTIFIED SOLUTION
Avatar of ramrom
ramrom
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mikezang
mikezang

ASKER

Yeah, if I put this file in Python folder, it is ok. but if I put it in other folder and copy xml folder to my work folder, I got such error, do you have any idea?
What do you mean "copy xml folder"? That's not the way you normally use python.
What happens if
cd C:\
python
import xml.dom.expatbuilder

If it fails you installation is not good.
I think Pythin is istanlled correctly without problems, because when I run code above in folder Python24, I got right result.

There is a application in different folder with its own python24, I added such code to its python source, when I run it, I got error "xml.dom not found".

So that I copy \Python24\lib\xml folder to that application's system folder, this time, the xml.dom.minidom is loaded, but I got error as ablove.

What can I do next?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That might be what I need! I will check it tonight!
By the way, Why Python installer dones't set PYTHONHOME auto?