Skip to content

Crashes on .NET Core 3 and 2 on Linux #967

Closed
@emilmuller

Description

@emilmuller

Can't make this work on Linux Mint 19 (Ubuntu 18.04).
Compiled ReleaseMonoPy3 with XPLAT;;PYTHON3;PYTHON37;UCS4;MONO_LINUX;PYTHON_WITH_PYMALLOC.
It seems to crash on Py.GIL():

using (Py.GIL())
{
    dynamic np = Py.Import("numpy");
    Console.WriteLine(np.cos(np.pi * 2));

    dynamic sin = np.sin;
    Console.WriteLine(sin(5));

    double c = np.cos(5) + sin(5);
    Console.WriteLine(c);

    dynamic a = np.array(new List<float> { 1, 2, 3 });
    Console.WriteLine(a.dtype);

    dynamic b = np.array(new List<float> { 6, 5, 4 }, dtype: np.int32);
    Console.WriteLine(b.dtype);

    Console.WriteLine(a * b);
    Console.ReadKey();
}

Upon further investigation, it seems to crash in InitializePlatformData(), as

IntPtr platformModule = PyImport_ImportModule("platform"); // Becomes NULL pointer

Running this line immediately after setting platformModule = ...

Console.WriteLine(new PythonException().Message);

yields:

ModuleNotFoundError : No module named '_posixsubprocess'

I also tried making sure the python home and path variables are correctly set:

PythonEngine.PythonHome = @"/usr/local/bin/python3.7";
PythonEngine.PythonPath = @"/usr/local/lib/python3.7";

I have no problem importing _posixsubprocess module when running the python3.7 binary from the terminal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions