Error when running a python file from matlab

Hi, I have a python file (Test.py) that shall be executed from a matlab file (Test_Matlab.m), both are in the same directory. In my matlab file I use "pyrunfile("Test.py")" to run the python file. The python file shall thereby open the program Dlubal RSTAB, create a new model and add a node in there (code thereof is attached at the end). However it doesnt work, I get the error "Python Error: ModuleNotFoundError: No module named 'dlubal'". When I run the python file directly it works without any problem, so I dont know what I do wrong. Thanks for a help (I use Matlab R2026a and Python 3.13.2).
Test.py Code:
from dlubal.api import rstab
# Option 1: Specify API key directly as a parameter
with rstab.Application(api_key_value="ak-92d9ffcc70bc4049a...", url="localhost", port=9000) as rstab_app:
print(rstab_app.get_application_info())
#Offene Modelle schließen
rstab_app.close_all_models(save_changes=False)
#Neues Modell anlegen
rstab_app.create_model(name="Test")
#Knoten definieren
my_node=rstab.structure_core.Node(
no=48,
coordinate_1=1.0,
coordinate_2=0.5,
coordinate_3=-2.0
)
#Knoten erzeugen
rstab_app.create_object(my_node)

1 comentario

It seems that the dlubal module is not installed properly.
Also you might want to check the python environment:
Verify the Python environment MATLAB is using:
pyenv
ans =
PythonEnvironment with properties: Version: "3.10" Executable: "/usr/bin/python3" Library: "libpython3.10.so.1.0" Home: "/usr" Status: NotLoaded ExecutionMode: InProcess
Then compare it with the Python environment where the script runs successfully:
If these paths are different, MATLAB is using a different Python installation.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Productos

Versión

R2026a

Preguntada:

el 2 de Jun. de 2026 a las 18:44

Comentada:

hace alrededor de 6 horas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by