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

Posted on 2006-04-05
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\", line 1915, in parse
    return expatbuilder.parse(file)
AttributeError: 'NoneType' object has no attribute 'parse'

Does anyone help me?
Question by:mikezang
    LVL 17

    Accepted Solution

    I tried that and it worked for me. So I guess something's wrong in the installation.
    LVL 5

    Author Comment

    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

    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.
    LVL 5

    Author Comment

    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

    set PYTHONHOME and copy expat.pyd
    LVL 5

    Author Comment

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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Installing Python 2.7.3 version on Windows operating system For installing Python first we need to download Python's latest version from URL" " You can also get information on Python scripting language from the above mentioned we…
    The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…

    755 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now