Blender crashes on startup, why? Trying to use blender on ubuntu 18.04 and I get the following error:

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast


Followed by a sigsegv.  I have an Nvidia graphics card and the output of the crash file is:

# Blender 2.79 (sub 0), Unknown revision

# backtrace
blender(BLI_system_backtrace+0x33) [0x555bdc475e93]
blender(+0x1040453) [0x555bdb9ff453]
/lib/x86_64-linux-gnu/libc.so.6(+0x3ef20) [0x7f5e92df9f20]
blender(GHOST_GetDPIHint+0) [0x555bdc493290]
blender(WM_window_set_dpi+0x12) [0x555bdba1f932]
blender(ED_screen_refresh+0xe9) [0x555bdbd171a9]
blender(ED_screens_initialize+0x2b) [0x555bdbd177eb]
blender(WM_check+0x68) [0x555bdb9fff58]
blender(wm_homefile_read+0x3c9) [0x555bdba0d5e9]
blender(WM_init+0x14b) [0x555bdba0fccb]
blender(main+0x241) [0x555bdb9bf0c1]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f5e92ddcb97]
blender(_start+0x2a) [0x555bdb9fc09a]


How do you fix this.
I found a clue here: https://askubuntu.com/questions/834254/steam-libgl-error-no-matching-fbconfigs-or-visuals-found-libgl-error-failed-t but was not happy with their solution.

I ended up reinstalling the nvidia drivers which had been removed during an abortive cuda install/removal.

sudo apt-get install nvidia-340

The version you need will be based on your graphics card and you can figure out that version with this page https://www.nvidia.com/Download/index.aspx?lang=en-us on the nvidia site.