Python xml module import problem

Hi, I've recently gotten interested in python on OS X and have run into a problem when attempting to import the xml module. I have been following this as a guide: http://www.python.org/doc/2.3/lib/dom-example.html

but when i attempt to execute the file, I get this error:

Traceback (most recent call last):   File "xml.py", line 1, in <module>     import xml.dom.minidom   File "/Users/robintibbs/xml.py", line 1, in <module>     import xml.dom.minidom ImportError: No module named dom.minidom  


I was under the impression the module I was trying to import was standard? Or am I attempting to import the incorrect module?

Many thanks in advance.

robin

MacBook 2GHz Core Duo, Mac OS X (10.5.1)

Posted on Dec 19, 2007 3:57 PM

Reply
6 replies

Dec 21, 2007 7:06 PM in response to RobinTibbs

{quote:title=RobinTibbs wrote:}Traceback (most recent call last):
File "xml.py", line 1, in <module>
import xml.dom.minidom
File "/Users/robintibbs/xml.py", line 1, in <module>
import xml.dom.minidom
ImportError: No module named dom.minidom
{quote}

Hi Robin,
Notice that the error message says "No module named dom.minidom" not "no module named xml.dom.minidom" - the module you are trying to import. This gives you a hint about what is going on: you are creating a "module" called xml that replaces the builtin xml module by naming your test script xml.py. Try renaming your test script (and be sure to delete the original script and anything called xml.pyc in your working directory).

Hope this helps,
Noah

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Python xml module import problem

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.