Comments

: when i try to run my code, i get a -> importerror: no module named dom. the first few lines of my code is below,: : import os: import time: import urllib: from xml.dom import minidom: from xml.sax.saxutils import escape: : why is there such an error? i tried a fresh install of python 2.4 but the same error occurs. i've uninstalled 2.4 and reinstalled 2.3.5. can anyone help?

Just to be clear, you get the error with 2.4 but not with 2.3.5?

Did you install any other packages with 2.3.5, like PyXML or anything like that?

: : when i try to run my code, i get a -> importerror: no module named dom. the first few lines of my code is below,: : : : import os: : import time: : import urllib: : from xml.dom import minidom: : from xml.sax.saxutils import escape: : : : why is there such an error? i tried a fresh install of python 2.4 but the same error occurs. i've uninstalled 2.4 and reinstalled 2.3.5. can anyone help?: : Just to be clear, you get the error with 2.4 but not with 2.3.5?: : Did you install any other packages with 2.3.5, like PyXML or anything like that?: : : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]: : [code]: $ select * from users where clue > 0: no rows returned: [/code]: :

i still get the error with 2.3.5. the funny thing is, the line "from xml.dom import minidom" works fine when i type it in IDLE. but when i open my program in IDLE, it wont run, giving the error mentioned above. i installed wxpython and py2exe but i remember trying to run the program with only python installed but still getting the error. any ideas?

: i still get the error with 2.3.5. the funny thing is, the line "from xml.dom import minidom" works fine when i type it in IDLE. but when i open my program in IDLE, it wont run, giving the error mentioned above. i installed wxpython and py2exe but i remember trying to run the program with only python installed but still getting the error. any ideas?

Wow, if it works interactively but not from a script then I am stumped. I would recommend posting a message to comp.lang.python. You can use Google Groups to do it if you've never posted to usenet before.

[b][red]This message was edited by Drost at 2005-3-31 6:22:44[/red][/b][hr][b][red]This message was edited by Drost at 2005-3-31 6:21:50[/red][/b][hr]: : : when i try to run my code, i get a -> importerror: no module named dom. the first few lines of my code is below,: : : : : : import os: : : import time: : : import urllib: : : from xml.dom import minidom: : : from xml.sax.saxutils import escape: : : : : : why is there such an error? i tried a fresh install of python 2.4 but the same error occurs. i've uninstalled 2.4 and reinstalled 2.3.5. can anyone help?: : : : Just to be clear, you get the error with 2.4 but not with 2.3.5?: : : : Did you install any other packages with 2.3.5, like PyXML or anything like that?: : : : : : [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]: : : : [code]: : $ select * from users where clue > 0: : no rows returned: : [/code]: : : : : : i still get the error with 2.3.5. the funny thing is, the line "from xml.dom import minidom" works fine when i type it in IDLE. but when i open my program in IDLE, it wont run, giving the error mentioned above. i installed wxpython and py2exe but i remember trying to run the program with only python installed but still getting the error. any ideas?:

Do you have a directory called xml beside your script? Which has "accidentally" an __init__.py in it? Which would mean to the parser that you want to use that self-made-module-which-consists-of-several-files (what are those actually called?)instead of the real one.

: Do you have a directory called xml beside your script? Which has "accidentally" an __init__.py in it? Which would mean to the parser that you want to use that self-made-module-which-consists-of-several-files (what are those actually called?)instead of the real one.: : Drost

no i dont. it wont have anything to do with how i name my files would it? i save my code as xml.py but python will look in its lib directory when i import right? i have no other files except for my xml.py

: : Do you have a directory called xml beside your script? Which has "accidentally" an __init__.py in it? Which would mean to the parser that you want to use that self-made-module-which-consists-of-several-files (what are those actually called?)instead of the real one.: : : : Drost: : no i dont. it wont have anything to do with how i name my files would it? i save my code as xml.py but python will look in its lib directory when i import right? i have no other files except for my xml.py:

Please rename it then to something else. IIRC the parser searches for external modules firstly in the same directory, the running script is in and only when it's not there would it look for it in different places...

: Please rename it then to something else. IIRC the parser searches for external modules firstly in the same directory, the running script is in and only when it's not there would it look for it in different places...: : Which in my opinion is a "Good Thing(TM)".: : Drost

ok i've renamed it and it works! i always thought python would still be able to find the required modules no matter how you name ur script?! well, thanks for all the help!

: : Please rename it then to something else. IIRC the parser searches for external modules firstly in the same directory, the running script is in and only when it's not there would it look for it in different places...: : : : Which in my opinion is a "Good Thing(TM)".: : : : Drost: : ok i've renamed it and it works! i always thought python would still be able to find the required modules no matter how you name ur script?! well, thanks for all the help!

Good job, Drost!

Python has to follow certain consistent rules when looking up objects by name. You asked it for something named "xml" and it found the first one it came across in its path of places to look (the current directory is first). Note that you can actually change the sys.path variable at runtime to let it look in other places.