Ren'Py [Atom.io] Import XML into Ren'Py ? importError : No module named...

Jul 1, 2018
31
24
Hi ! So here's my situation : In my game, I have a large function designed for each of the girls I create, which, depending on the hour and day, affects their "where" value at the declared situation. I have no issue with that, but because it's a mess, and also because I wanted to improve my way of creating games efficiently, I decided to learn XML to transfer data files from Excel into my game, to have a better view of the schedules of all my girls, and also to make it less a mess in my code.
So I've spent the day learning all the stuff I needed, how to create a xml from excel, how to make it functionnal, how to import it to python, and finally how to store the required values anytime I need them. Everything on PyCharm (Python IDE) works perfectly fine, but when I install my code into my .rpy files, it doesn't work. And the issue is simple :

I'm sorry, but an uncaught exception occurred.

While running game code:
File "game/script.rpy", line 2, in script
init python:
File "game/script.rpy", line 3, in <module>
import xml.dom.minidom
ImportError: No module named dom.minidom
I've tried putting it into "init python", without, into a .py file and then importing it with and w/out "init python", and nothing does it. The only Ren'Py page I've found about XML is outdated and did not resolve my problem.
 

Porcus Dev

Engaged Member
Game Developer
Oct 12, 2017
2,582
4,705
Does this help?


or

 

Rich

Old Fart
Modder
Donor
Respected User
Game Developer
Jun 25, 2017
2,566
7,384
Just because you code in an "import" doesn't guarantee that the Python module is actually there. Ren'py doesn't necessarily include every Python module under the sun - only the ones it needs to do its job.

Looking at the ren'py SDK, it looks like it has "xml.etree" and "xml.parsers," but not "xml.dom." Thus, if you want to use that module, you'll have to actually copy the Python source code for the "xml.dom" module into your game.
 
Jul 1, 2018
31
24
Does this help?


or

Nope, doesn't work. Those are both different issues (first one is a guy trying to modify the renpy editor, and second is someone that had a file named xml.py that was corrupting the way his python code worked), but thanks for the answer :)

Just because you code in an "import" doesn't guarantee that the Python module is actually there. Ren'py doesn't necessarily include every Python module under the sun - only the ones it needs to do its job.

Looking at the ren'py SDK, it looks like it has "xml.etree" and "xml.parsers," but not "xml.dom." Thus, if you want to use that module, you'll have to actually copy the Python source code for the "xml.dom" module into your game.
I'm trying to see how xml.etree works, but my brain is overheating trying to figure out how each attribute of etree works without examples online.
How can I find the Python source code for xml.dom ? Because I thought about that, but I didn't find anything talking about this.

EDIT : Found where the xml libraries are stored in my computer, but now, what do I do ? I tried putting them inside my game files, but doesn't change anything. I tried modifying the Ren'Py launcher to include the lib, but this just made the launcher not start :LOL:
 
  • Like
Reactions: Porcus Dev
Jul 1, 2018
31
24
Ok so I just learned how xml.etree worked, and it's WAY MORE EASIER than xml.dom in the end. The way to access the files is simpler, I just need to test that on Ren'Py now.
EDIT : Works perfectly ! I recommend and can give help now :)
 
  • Like
Reactions: Saki_Sliz