Initializing gmsh influences path environment in python on windows
I am developing a python program that automatically creates meshes using the gmsh python api and then calls Elmer FEM to solve the heat equation. However python can't find the ElmerSolver executable after initializing gmsh:
import gmsh import subprocess subprocess.run(['ElmerSolver']) # works gmsh.initialize() subprocess.run(['ElmerSolver']) # FileNotFoundError gmsh.finalize() # still doesn't work after finalizing gmsh
It always works with absolute paths, but some internal dependencies inside Elmer are broken. My workaround is to call the script creating the geometry separately:
import subprocess subprocess.run(['python', 'my_gmsh_script.py']) subprocess.run(['ElmerSolver'])
I use the latest gmsh release (4.7.1), python 3.8.5 on windows 10.