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

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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

제품

릴리스

R2026a

질문:

2026년 6월 2일 18:44

댓글:

2026년 6월 12일 3:22

Community Treasure Hunt

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

Start Hunting!

Translated by