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?
LVL 5
mikezangAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ramromconsultant Commented:
I tried that and it worked for me. So I guess something's wrong in the installation.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mikezangAuthor Commented:
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?
mish33Commented:
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.
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

mikezangAuthor Commented:
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?
mish33Commented:
set PYTHONHOME and copy expat.pyd
mikezangAuthor Commented:
That might be what I need! I will check it tonight!
By the way, Why Python installer dones't set PYTHONHOME auto?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.