SciSharp / Numpy.NET

C#/F# bindings for NumPy - a fundamental library for scientific computing, machine learning and AI
Other
691 stars 98 forks source link

Failure out-of-the-box #38

Closed pavlexander closed 2 years ago

pavlexander commented 4 years ago

I am running a very trivial .net core app with code as simple as that:

    static async Task Main(string[] args)
    {
        Console.WriteLine("Starting test application!");

        var m = np.array(new int[] { 1, 2, 3, 4 });

        Console.WriteLine("");
        Console.WriteLine("Press any key to exit..");
        Console.ReadKey();
    }

Exceptions is thrown at numpy line:

System.IO.FileNotFoundException: 'Could not load file or assembly 'pickle5, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'

if I click continue:

System.IO.FileNotFoundException: 'Could not load file or assembly 'org, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'

continue:

System.IO.FileNotFoundException: 'Could not load file or assembly 'org.python, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'

continue:

System.IO.FileNotFoundException: 'Could not load file or assembly 'org.python.core, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'

continue:

System.IO.FileNotFoundException: 'Could not load file or assembly 'pwd, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'

etc...

System.IO.FileNotFoundException: 'Could not load file or assembly 'grp, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.'

after about 6-7 more exceptions code is finally executed and seems to be running fine.. but why are so many exceptions thrown?

numpy: 3.7.1.14 running in x64 .net core 3.1

Needless to say I don't have python installed

pavlexander commented 4 years ago

just checked. no such exceptions with NumSharp library.. there seems to be some differences between them. I will be using the later one in a meanwhile, but I would appreciate to hear some ideas of why the first fails.

henon commented 4 years ago

operating system?

pavlexander commented 4 years ago

Sorry, here they are: OS Name: Microsoft Windows 10 Pro Version: 10.0.18363 Build 18363

Data from VS:

Microsoft Visual Studio Community 2019 Version 16.5.4 VisualStudio.16.Release/16.5.4+30011.22 Microsoft .NET Framework Version 4.8.03752

Installed Version: Community

Visual C++ 2019 00435-60000-00000-AA247 Microsoft Visual C++ 2019

ASP.NET and Web Tools 2019 16.5.236.49856 ASP.NET and Web Tools 2019

ASP.NET Web Frameworks and Tools 2019 16.5.236.49856 For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 16.5.236.49856 Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 16.5.236.49856 Azure Functions and Web Jobs Tools

C# Tools 3.5.0-beta4-20153-05+20b9af913f1b8ce0a62f72bea9e75e4aa3cf6b0e C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

IntelliCode Extension 1.0 IntelliCode Visual Studio Extension Detailed Info

Markdown Editor 1.12.253 A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown.

Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2019 - v2.9.30207.1

Microsoft Continuous Delivery Tools for Visual Studio 0.4 Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 2.1.25+gdacdb9b7a1 Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual C++ Wizards 1.0 Microsoft Visual C++ Wizards

Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package

NuGet Package Manager 5.5.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

NVIDIA CUDA 10.2 Wizards 10.2 Wizards to create new NVIDIA CUDA projects and source files.

NVIDIA Nsight Visual Studio Edition 2019.4.0.19274 NVIDIA Nsight Visual Studio Edition provides tools for GPGPU and graphics development. Copyright © NVIDIA 2010 - 2019. •Direct3D® and DirectX® are registered trademarks of Microsoft Corporation in the United States and/or other countries. •Microsoft Detours is used under the Professional license (http://research.microsoft.com/en-us/projects/detours/). •Gardens Point Parser Generator Copyright 2005 Queensland University of Technology (QUT). All rights reserved. •NLog Copyright © 2004-2006 Jaroslaw Kowalski (jaak@jkowalski.net) •IronPython and WPFToolkit used under Microsoft Public License (Ms-PL) and are Copyright © Microsoft Corporation •Portions of RadControls for WPF © 2010-2011 by Telerik Corporation. All rights reserved. •zlib and libpng used under the zlib/libpnc license (http://opensource.org/licenses/Zlib) •QtSingleApplication Copyright 2013 Digia Plc and/or its subsidiary(-ies). •Font Awesome Copyright 2018 Fonticons, Inc.

Warning: This computer program is protected by copyright law and international treaties. Unauthorized reproduction or distribution of this program, or any portion of it, may result in severe civil and criminal penalties, and will be prosecuted to the maximum extent possible under the law.

NVIDIA Nsight Visual Studio Edition - CUDA support 2019.4.0.19274 NVIDIA Nsight Visual Studio Edition - CUDA support provides tools for CUDA development and debugging.

ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info

SQL Server Data Tools 16.0.62003.05170 Microsoft SQL Server Data Tools

Test Adapter for Boost.Test 1.0 Enables Visual Studio's testing tools with unit tests written for Boost.Test. The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test 1.0 Enables Visual Studio's testing tools with unit tests written for Google Test. The use terms and Third Party Notices are available in the extension installation directory.

TypeScript Tools 16.0.20225.2001 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 3.5.0-beta4-20153-05+20b9af913f1b8ce0a62f72bea9e75e4aa3cf6b0e Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.8.0.0 for F# 4.7 16.5.0-beta.20181.6+85af456066acd4e76d2bc7821b44a325e46f2fca Microsoft Visual F# Tools 10.8.0.0 for F# 4.7

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Container Tools Extensions (Preview) 1.0 View, manage, and diagnose containers within Visual Studio.

Visual Studio Tools for CMake 1.0 Visual Studio Tools for CMake

Visual Studio Tools for Containers 1.0 Visual Studio Tools for Containers

pavlexander commented 4 years ago

To reproduce the issue you must have "CLR exceptions" fully enabled like so:

image

henon commented 4 years ago

I checked in NetCoreTest under Examples and even with the exceptions enabled I can't reproduce this on win10. Can you fork and analyse the differences between your test project and mine?

pavlexander commented 4 years ago

it is failing on my machine as well :) image Note that you are using the .Net core 2.2 whereas I reported on 3.1.. But it is irrelevant because both versions fail identically, as long as I have the checkbox selected for CLR Exceptions as mentioned above.

henon commented 4 years ago

Strange that I don't see the exception. Can you show me all your exception settings? As long as I can't reproduce it I can't really fix it.

In any case, it is not a big problem. Most operations don't require pickle and the other dependencies it is missing.

pavlexander commented 4 years ago

Well, from the previous exception you can see that the type is "System.IO.FileNotFoundException", so if you want to catch it - you have to have that option ticked at least. But you should really just select all of them. Here are some settings but I don't think having the full list is important. All the default settings here, except for CLR.

image

image

I have just found out another mandatory condition. You have to have "Just my code" option unselected in debug settings:

image

I hope it's the last condition. When it's ticked I don't have exceptions thrown even with the CLR exceptions option selected...

let me know if you are still unable to reproduce, I will then check other options in VS settings..

henon commented 4 years ago

OK, with "Just My Code" ticked off I get the exception now

adscott1982 commented 3 years ago

Was this issue ever fixed? I am getting the same issue using PythonNet when importing a module from C#.

henon commented 3 years ago

but only in Debug mode right? I had the impression that these are exceptions which are natural and which are catched. I mean does it really have any functional consequences?

adscott1982 commented 3 years ago

Probably has no consequences. I am sure the exceptions also happen in release, but as you say they are caught. You only see it when you turn on the option to break on any CLR exception. I am having a different issue with PythonNet, and was wondering if this was related. If I can fix it, it would help me rule out the problems being related.

henon commented 3 years ago

Well, Numpy.NET uses pythonnet and the exceptions happen in their code. I would say that the python interpreter is trying to load libraries which are simply not present in the stripped down embedded python distribution. You can easily check if they happen when you start a clean .net project, load pythonnet and import numpy.