• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2995
  • Last Modified:

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?
  • 3
  • 2
2 Solutions
ramromconsultant Commented:
I tried that and it worked for me. So I guess something's wrong in the installation.
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?
What do you mean "copy xml folder"? That's not the way you normally use python.
What happens if
cd C:\
import xml.dom.expatbuilder

If it fails you installation is not good.
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

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?
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?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now