Я хотел попробовать Numpy. Net с F #, используя среду anaconda в Ubuntu 18.04.3 с VS Code.
Сначала я создал новую среду conda conda create --name fsharp371 python=3.7.1
Затем conda activate fsharp371
и pip install numpy=1.16
Инициируйте проект через dotnet new console -lang "F#" -o NumpyTest
, затем export LD_LIBRARY_PATH="/home/hnc/.conda/envs/fsharp371/bin"
и dotnet add package Keras.NET.Mono --version 3.7.4.1
Мой код очень просто:
// Learn more about F# at http://fsharp.org
open System
open Numpy
[<EntryPoint>]
let main argv =
let arr = Numpy.np.array [|10;20;30|]
printfn "Hello World from F#!"
0 // return an integer exit code
Однако с dotnet run
я получаю:
Unhandled exception. System.Exception: dlsym: /home/hnc/Documents/github/NumpyTest/bin/Debug/netcoreapp3.1/NumpyTest: undefined symbol: _PyObject_NextNotImplemented
at Python.Runtime.NativeMethods.GetProcAddress(IntPtr dllHandle, String name)
at Python.Runtime.Runtime.Initialize(Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv, Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize(Boolean setSysArgv, Boolean initSigs)
at Python.Runtime.PythonEngine.Initialize()
at Numpy.np.InstallAndImport(Boolean force)
at Numpy.np.<>c.<.cctor>b__599_0()
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy`1.CreateValue()
at System.Lazy`1.get_Value()
at Numpy.np.get_self()
at Numpy.np.get_int32()
at Numpy.DtypeExtensions.GetDtype(Object obj)
at Numpy.np.array[T](T[] object, Dtype dtype, Nullable`1 copy, String order, Nullable`1 subok, Nullable`1 ndmin)
at Numpy.np.array[T](T[] data)
at Program.main(String[] argv) in /home/hnc/Documents/github/NumpyTest/Program.fs:line 13