Error when running a python file from matlab
Mostrar comentarios más antiguos
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.
Please refer to this documentation which might help in package install related issue. https://www.dlubal.com/en/support-and-learning/support/faq/005737?srsltid=AfmBOoqFh7Psg9SNTHRA0mwUlo1NXZfUv5DPTM2wTcWZHBG1aE6THsBN
Also you might want to check the python environment:
Verify the Python environment MATLAB is using:
pyenv
Then compare it with the Python environment where the script runs successfully:
If these paths are different, MATLAB is using a different Python installation.
Respuestas (0)
Categorías
Más información sobre Call Python from MATLAB en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!