-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error importing numpy from Dotnet on Ubuntu #401
Comments
The dotnet code to call into the library is : using System.Runtime.InteropServices;
namespace Demo
{
static class Program
{
[DllImport("demo_rs", CallingConvention = CallingConvention.Cdecl)]
private static extern void hello_world();
static void Main(string[] args)
{
Console.WriteLine("Starting C# code");
hello_world();
}
}
} |
Uff, if this is specific to embedding into a .NET binary, then I cannot really add anything. Personally, I would start grepping the NumPy source tree for that error message to understand why NumPy thinks that it was loading from its source tree. |
I had this kind of error on OSX when there was a mismatch between the Rust architecture and the Python one. |
Same error on wsl2 ubuntu 22.04, using rust flutter bridge to call python code |
Hi,
I am building a Rust dynamic library embedding Python using rust-numpy. My project allows me to build a pure Rust binary, a C binary loading the Rust library and a Dotnet binary loading the Rust library. All three scenarios works on Windows but fails on Linux with "Error importing numpy".
The following code built as a cdylib is enough to reproduce the problem when imported into a Dotnet SDK 6.0 or 7.0 program
On Windows, the code succeeds
On Ubuntu, the code fails
The error triggers on import of numpy whether we use Rust PyArray or do a import numpy in Python. Removing references to numpy allows to execute Python code with success. For instance, I can print some informations from within Dotnet > Rust > Python as follows :
Numpy was installed using pip3, but I don't think it has anything to do with my Python setup since the dynamic library works when tested from a C code. It seems the error message may be giving a false indication as to the real cause of the error.
Any help would be greatly appreciated!
The text was updated successfully, but these errors were encountered: