- Index
- » Users
- » linksse
- » Profile
Posts
Posts
Hello Adeel,
I've already done that
Thats how I've succeded to compile my model.
Dear all,
I am using OMEdit and I have written a model which calls a Python function that I have embedded following Interoperabilty C and Python advices. I cannot find where to set the C compiler flags like
Code:
-I"C:\path" -L"Library\path" -lpython37
.
Furthermore, I am using an Anaconda python distribution, where can I set my PATH and PYTHONPATH (I have no admin rights so, I need to set them in a batch file).
Thank you all,
Dear all,
I have writen a Modelica model in which I have a function that calls a python script. This is done following the Interoperability C and Python advices. However, I am using an Anaconda3 python installation. I have managed to compile my code without any problem, I have tested it in command line with success. However, when running the simulation in OMEdit, the code compiles right but the simulation fails. Indeed, I think it is because of the PATH variable, wich modelica cleans and sets.
Could anyone please help me to modify the PATH variable in the OMEdit GUI please or to find the right SCRIPT where it is set? And to set correctly also my PYTHONPATH.
In advance, thank you
Dear adrpo,
Thank you very much for the package. I am using python 3.7 with anaconda. I have changed the Py.run print command with the parenthesis and the python37.dll in both "om" files. However, even if the compilation is finished without errors, I have an error with the encoding:
Fatal Python error: initfsenconding: unable to laod the file system codec
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00002314 (most recent call first):
Simulation process failed. Exited with code 3
By the way, the OMCallPython.h file is something that you have written or it can be generated easily for a more complex python code?
Thank you very much!
Anyone? Please?
Dear modellica users,
I am quiet new in Modelica and trying to create a model to be exported into an FMU. Right now I am looking for tutorials to understand how modelica works and cannot achieve to execute a very simple python script inside a model. I have found this “Interoperability – C and Python”:
https://openmodelica.ida.liu.se/doc/OpenModelicaUsersGuide/latest/interop_c_python.html
But it does not give the structure of the python script.
I have created a pyRunString.py script with the following:
Code:
def pyRunString(s):
print(s)
And I have compilation errors:
When keeping the line
Code:
Py_SetProgramName(\"pyRunString\"); /* optional but recommended */
I get:
Code:
In file included from CallExternalPython_functions.c:7:0:
CallExternalPython_includes.h: In function 'pyRunString':
CallExternalPython_includes.h:9:21: warning: passing argument 1 of 'Py_SetProgramName' from incompatible pointer type [-Wincompatible-pointer-types]
Py_SetProgramName("pyRunString"); /* optional but recommended */
^
In file included from C:/Users/cabecerrilaguirre/AppData/Local/Continuum/anaconda3/include/Python.h:140:0,
from CallExternalPython_includes.h:5,
from CallExternalPython_functions.c:7:
C:/Users/cabecerrilaguirre/AppData/Local/Continuum/anaconda3/include/pylifecycle.h:40:18: note: expected 'const wchar_t * {aka const short unsigned int *}' but argument is of type 'char *'
PyAPI_FUNC(void) Py_SetProgramName(const wchar_t *);
When I delete it:
Code:
CallExternalPython_functions.o:CallExternalPython_functions.c:(.text+0xb): undefined reference to `__imp_Py_Initialize'
CallExternalPython_functions.o:CallExternalPython_functions.c:(.text+0x18): undefined reference to `__imp_PyRun_SimpleStringFlags'
CallExternalPython_functions.o:CallExternalPython_functions.c:(.text+0x24): undefined reference to `__imp_Py_Finalize'
collect2.exe: error: ld returned 1 exit status
CallExternalPython.makefile:32: recipe for target 'omc_main_target' failed
mingw32-make: *** [omc_main_target] Error 1
mingw32-make: Leaving directory 'C:/Users/CABECE~1/AppData/Local/Temp/OPENMO~1'
RESULT: 2
Could you please somebody help me to understand?
- Index
- » Users
- » linksse
- » Profile