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

Posted on 2006-04-05
Medium Priority
Last Modified: 2012-06-27
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?
Question by:mikezang
  • 3
  • 2
LVL 17

Accepted Solution

ramrom earned 100 total points
ID: 16383721
I tried that and it worked for me. So I guess something's wrong in the installation.

Author Comment

ID: 16385641
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?
LVL 15

Expert Comment

ID: 16389081
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.
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Author Comment

ID: 16389101
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?
LVL 15

Assisted Solution

mish33 earned 100 total points
ID: 16389221
set PYTHONHOME and copy expat.pyd

Author Comment

ID: 16389253
That might be what I need! I will check it tonight!
By the way, Why Python installer dones't set PYTHONHOME auto?

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction On September 29, 2012, the Python 3.3.0 was released; nothing extremely unexpected,  yet another, better version of Python. But, if you work in Microsoft Windows, you should notice that the Python Launcher for Windows was introduced wi…
Article by: Swadhin
Introduction of Lists in Python: There are six built-in types of sequences. Lists and tuples are the most common one. In this article we will see how to use Lists in python and how we can utilize it while doing our own program. In general we can al…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question