Skip to content

nuget error - windows 10 - Anaconda Python 3.5.2 64 bit #472

Closed

Description

@den-run-ai

from @mphielipp

Hi, I install this package. But when I run the project I get a runtime error . I have a Anaconda Python 3.5.2 64 bits install. I use the Nuget PAckage 3.5. I have tried to run it with x86, Any CPU, amd x64. Any suggestions?

Now I'm running x86. Crash in this line Py.GIL().
There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "Python.Runtime, Version=2.3.0.0, Culture=neutral, processorArchitecture=x86", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. PythonNet2

Windows 10

I installed it using the "MAnage Nuget Package" option in Visual Studio 2005.

I changed the "Target Platform Option" in project settings to x86. But I still get this runtime error in the same line:

An unhandled exception of type 'System.BadImageFormatException' occurred in Python.Runtime.dll

Additional information: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

Activity

  1. den-run-ai commented on May 25, 2017

    @den-run-ai
    ContributorAuthor

    @mphielipp are you really using VS 2005??? Your anaconda is clearly 64-bit, hence you need to select x64 target in VS. Which nuget pythonnet package did you install? There are many versions of them.

    What .NET runtime are you targetting?

    What do these commands show?

    where python
    python --version

  2. mphielipp commented on May 25, 2017

    @mphielipp

    VS 2015
    C:\Users<ny user>\AppData\Local\Continuum\Anaconda3\python.exe
    Python 3.5.2 :: Anaconda 4.3.1 (64-bit)

  3. mphielipp commented on May 25, 2017

    @mphielipp

    .NET Framework 4.5.2

  4. mphielipp commented on May 25, 2017

    @mphielipp

    pythonnet_py35_dotnet 2.3.0

  5. den-run-ai commented on May 25, 2017

    @den-run-ai
    ContributorAuthor

    I see the issue, nuget does not switch automatically the version of package (x86 and x64) depending on the architecture:

    https://stackoverflow.com/questions/7769580/how-should-i-create-or-upload-a-32-bit-and-64-bit-nuget-package

  6. vmuriart commented on May 25, 2017

    @vmuriart
    Contributor

    @denfromufa looks like you arrived to the same solution we did. We got it fixed by manually updating the dll reference to the 64bit version. I don't know how other libraries deal w this though, dllexport and nunit may have some solution for this.

  7. added this to the 2.4.0 milestone on Jun 14, 2017
  8. STREETKILLER007 commented on Aug 14, 2018

    @STREETKILLER007

    @denfromufa i would like to confirm my understanding on this issue.
    Do you mean that currently, the System.BadImageFormatException error still have not been solve if we downloaded Pythonnet from NuGet ?

  9. den-run-ai commented on Aug 14, 2018

    @den-run-ai
    ContributorAuthor
  10. filmor commented on Aug 30, 2018

    @filmor
    Member

    I don't think this is something we can easily solve in code. We could, however, provide different NuGet packages for all relevant arch/python version combinations.

  11. lostmsu commented on Dec 2, 2018

    @lostmsu
    Member

    @filmor this should be possible with the new .NET Core nuget packages. They even support different target platforms.

  12. filmor commented on Dec 2, 2018

    @filmor
    Member

    That would still not solve the issue of different Python versions, would it?

  13. lostmsu commented on Dec 3, 2018

    @lostmsu
    Member

    @filmor , no, it would not. Python versions issue, IMHO, should either be solved by having separate NuGet package names per python version (e.g pythonnet36 instead of pythonnet), or by having all versions in a single package.

  14. den-run-ai commented on Dec 3, 2018

    @den-run-ai
    ContributorAuthor

    @lostmsu can you provide references for the new nuget package specs of platform definitions?

  15. lostmsu commented on Dec 3, 2018

    @lostmsu
    Member

    @denfromufa , I can't find a tutorial, but this is what I am talking about: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog

  16. den-run-ai commented on Dec 3, 2018

    @den-run-ai
    ContributorAuthor
  17. modified the milestones: 2.4.0, 2.5.0 on Apr 12, 2019
  18. modified the milestones: 2.5.0, 3.0.0 on Apr 23, 2020
  19. lostmsu commented on Sep 24, 2021

    @lostmsu
    Member

    This has been solved with the introduction of clr_loader for Python and Runtime.PythonDLL for .NET side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions