Maybe you have the newer python6 on Ubuntu or the .so file has a different link
name ? For me the second example compiles without error on openSuse Tumbleweed.
# The imported Python3 initialization function
proc initialize*(){.cdecl, importc: "Py_Initialize" dynlib:
"libpython3.6m.so.1.0".}
# The module's init function
proc PyInit_nim_module() {.cdecl, exportc.} =
{.emit: """NimMain();""".}
initialize() #
Your first example does not compile , some error in nim_lexers.
