Netgen over a remote connection requiring display

HI All,

I am trying to use Netgen over a remote desktop connection via an ubuntu terminal without an attached display. My understanding is that

$ netgen -geofile=example.geo -meshfile=example.vol - coarse -batchmode

would generate a mesh of example.geo without opening a gui interface. Is that correct? I am getting tkinter errors about connecting to a display:

Traceback (most recent call last):
File “/home/james/.local/bin/netgen”, line 8, in
File “/home/james/.local/lib/python3.10/site-packages/netgen/”, line 45, in main
from .gui import win
File “/home/james/.local/lib/python3.10/site-packages/netgen/”, line 48, in
File “/home/james/.local/lib/python3.10/site-packages/netgen/”, line 20, in StartGUI
win = Tk()
File “/usr/lib/python3.10/tkinter/”, line 2299, in init = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: couldn’t connect to display “localhost:0.0”


in your command is the space between the - and coarse on purpose or a copy mistake?
Because if I remove the space your command works for me.

But how did you install ngsolve? Using provided installer, apt or pip installer?

Hi Christopher,
Thanks for the prompt reply.

The space between the - and coarse was a copying mistake I made when I typed my original forum post.
I’ve installed ngsolve via the pip installer.


Hi James,

The “netgen” executable in the pip installer is actually a python script, not implementing all the options from the “legacy” executable you get when you compile the code yourself. (has to do with python packaging and linkage).

In your case I would write a short python script to do the meshing and run it:

[code]from netgen.csg import *

geom = CSGeometry(“some_file.geo”)
mesh = geom.GenerateMesh(meshsize.coarse)