Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
1

Dymola-Python Interface. No module named Dymola

asked 2023-01-23 12:31:58 -0500

rb8685's avatar

updated 2023-01-24 09:04:03 -0500

I have been working trying to run Dymola through python. The goal is to give in values and read results without opening Dymola. The constant error that i am getting is "There is no module named Dymola" Please help!! I couldn't find much help online. Thank you in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-01-27 02:27:11 -0500

Without your test script or more info, it's hard to tell whether you have incorrectly configured the path to the Dymola python module or whether it's another issue (like casing, the module is apparently dymola, not Dymola)

(It also doesn't help that I don't use windows neither do I use Dymola... :))

Seems like it should probably start with from dymola.dymola_interface import DymolaInterface, and if you aren't setting your PYTHONPATH variable before launching python (set PYTHONPATH=%PYTHONPATH%;C:\Path\to\Dymola\Modelica\Library\python_interface\dymola.egg), you should have something like his before trying to use dymola:

import sys
from pathlib import Path
DYMOLA_INSTALL_PATH = Path(r'C:\path\to\Dymola\')
DYMOLA_EGG = DYMOLA_INSTALL_PATH / 'Modelica/Library/python_interface/dymola.egg'
sys.path.insert(0, str(DYMOLA_EGG))

from dymola.dymola_interface import DymolaInterface
dymola = DymolaInterface()
res = dymola.simulate("myModel")

Personal 2 cents: I generally recommend using the sys.path.insert inside the script approach instead of setting the PYTHONPATH env variable, you'll avoid some issues.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Careers

Question Tools

1 follower

Stats

Asked: 2023-01-23 12:31:58 -0500

Seen: 383 times

Last updated: Jan 27 '23