I'm trying to make an .exe file of a python script using the cantera library with help of PyInstaller module.
I'm working with python 3.9 and Pyinstaller 5.13.1.
My Script is very simple :
import numpy as np
import cantera as ct
print(np.zeros(2))
S = ct.Solution('gri30.cti')
I'm working in virtual environnement with all packages necessary installed. When I execute my script with python in venv everything is ok, the script work well.
I can generate the .exe file with this command line : pyinstaller script.py --collect-all cantera
The .exe is correctly created is dist folder.
When I execute the .exe in the virtual env everything is ok, but when I try to run it in arbitrary folder I have this log :
[0. 0.]
Traceback (most recent call last):
File "\\t-vgate-3\\dev1\tst.py", line 7, in <module>
S=ct.Solution("C:\\Users\\Downloads\\gri30.cti")
File "build\python\cantera\base.pyx", line 71, in cantera._cantera._SolutionBase.__cinit__
File "build\python\cantera\base.pyx", line 137, in cantera._cantera._SolutionBase._cinit
File "build\python\cantera\base.pyx", line 256, in cantera._cantera._SolutionBase._init_cti_xml
cantera._cantera.CanteraError:
*******************************************************************************
CanteraError thrown by call_ctml_writer:
Error converting input file "C:\Users\Downloads\gri30.cti" to CTML.
Python command was: 'python'
The exit code was: 1
-------------- start of converter log --------------
sys.path: ['', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\win32', 'C:\\Python27\\lib\\site-packages\\win32\\lib', 'C:\\Python27\\lib\\site-packages\\Pythonwin', 'C:\\Python27\\lib\\site-packages\\wx-2.8-msw-unicode']
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
File "cantera\__init__.py", line 4, in <module>
from ._cantera import *
ImportError: No module named _cantera
--------------- end of converter log ---------------
*******************************************************************************
[14960] Failed to execute script 'test' due to unhandled exception!
In this case, numpy seems to work well but not cantera.
I think that Cantera doesn't use the python interpreter of the .exe file.
Somebody have an idea to solve this issue ? Or maybe some test to do ?
Thanks a lot for your help.