Problem running Netgen in batchmode with macOS Big Sur

Hello,

I have just upgraded to macOS Big Sur and am using python 3.8.2 and NGSolve 6.2.2102. I am trying to run netgen in batchmode from a python script. I am using the command

subprocess.call(['netgen','-geofile=my_geometry.geo','-meshfile=my_mesh.vol','-coarse','-batchmode'])

Which I believe to be equivalent to

$ netgen -geofile=my_geometry.geo -meshfile=my_mesh.vol -coarse -batchmode

However, the second works but the first does not and I receive the following error

Error in Tcl-Script:
result = dlopen(libgui.dylib, 6): image not found

Make sure to set environment variable NETGENDIR to directory containing ng.tcl

I have been running the first line of code on macOS High Sierra and I believe the only thing I have changed is my OS. Could you please advise if there is something I have missed or if there is an easy work around?

Kind regards,

Ben

Hi Ben,

Try to pass shell=True to subprocess.call. Otherwise, your .bash_profile file is not executed and environment variables like NETGENDIR are not defined.

Best,
Matthias

Hi Matthias,

Thank you for your speedy reply. I have tried implementing shell=True as you suggested but am still getting the same error. You seem to suggest it is an issue when sourcing .bash_profile using subprocess though, so I will look at that and see whether I can find anything and if not I will come back. Thank you for your help.

Kind regards,

Ben