weird python problem

Joined
Apr 4, 2003
Messages
836
hey, all. i'm pretty new to python, so i'm not understanding what is causing this error.

from the interpreter, when i use the command shown
Code:
from xml.dom import minidom

i get

Code:
>>> from xml.dom import minidom
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/uname/xml.py", line 3, in <module>
    from xml.dom import minidom
ImportError: No module named dom

but let me explain something first... i was doing the same work on this machine just an hour ago and that very import line worked. no joke! what could have changed?

thanks.
 
The most likely thing is that you're doing this in a program/interpreter session where you've already defined xml to be something else, like a string containing your xml.
 
if the previous answer didnt solve it, does it still do that when you open up a brand new interpreter ?

If you have a python version older than 2.0 you won't have minidom either.
 
sorry about my slow reply... got busy last night and then the internet went down.

so i ssh'd back into the box and here's what happened when i fired python back up and tried again

Code:
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from xml.dom import minidom
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/uname/xml.py", line 3, in <module>
    from xml.dom import minidom
ImportError: No module named dom
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python2.5/site-packages/apport_python_hook.py", line 38, in apport_excepthook
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python2.5/site-packages/apport/__init__.py", line 1, in <module>
    from apport.report import Report
  File "/usr/lib/python2.5/site-packages/apport/report.py", line 17, in <module>
    import xml.dom, xml.dom.minidom
  File "/home/uname/xml.py", line 3, in <module>
    from xml.dom import minidom
ImportError: No module named dom

Original exception was:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/uname/xml.py", line 3, in <module>
    from xml.dom import minidom
ImportError: No module named dom
>>>

mind you, this is the first time today that i tried to import this package.

i think the python daemon (or whatever the proper term would be) needs to be restarted, but since i'm not an admin or in wheel, i can't do it. is there some method that a normal user can employ to flush out the old errors and fix this mess?

as i said, i used this module (minidom) successfully yesterday on the same machine.

thanks for your input.
 
Its possible something could be wrong with the python that they installed. I would first check to see if the minidom.py file even exists. On my system its at: d:\python25\lib\xml\dom\minidom.py & minidom.pyc

I'd start by doing a find -name minidom.py /usr/lib/python2.5
to see if minidom.py exists. If its not there try doing a find on the root (/) if that wont be too disruptive.

If that file exists, theres the possibility your PYTHONPATH is broken. You'll have to check the docs on python.org (or google) for how its supposed to be setup under linux.
 
okay, thanks for that. the file exists, so i'll assume that the PYTHONPATH is broken. I'll do some googling on how to fix that and if i find anything, i'll post back.
 
Assuming that /home/uname is your home directory, the problem is that you have an xml.py in your home directory. The first place that the Python interpreter will look for an include file is in the current directory.
 
ahh, good call! that was exactly the problem. glad i didn't shoot out that email to the support staff yet :)

...is it at all an excuse that this is only my 4th day of python programming?

thanks again!
 
yer don't call yr custom modules the name of a already provided module
 
Back
Top