You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
nuget error - windows 10 - Anaconda Python 3.5.2 64 bit #472
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)
@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.
@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.
@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 ?
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.
@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.
Activity
den-run-ai commentedon May 25, 2017
@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 pythonpython --versionmphielipp commentedon May 25, 2017
VS 2015
C:\Users<ny user>\AppData\Local\Continuum\Anaconda3\python.exe
Python 3.5.2 :: Anaconda 4.3.1 (64-bit)
mphielipp commentedon May 25, 2017
.NET Framework 4.5.2
mphielipp commentedon May 25, 2017
pythonnet_py35_dotnet 2.3.0
den-run-ai commentedon May 25, 2017
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
vmuriart commentedon May 25, 2017
@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.
STREETKILLER007 commentedon Aug 14, 2018
@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 ?
den-run-ai commentedon Aug 14, 2018
filmor commentedon Aug 30, 2018
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.
lostmsu commentedon Dec 2, 2018
@filmor this should be possible with the new .NET Core nuget packages. They even support different target platforms.
filmor commentedon Dec 2, 2018
That would still not solve the issue of different Python versions, would it?
lostmsu commentedon Dec 3, 2018
@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.
den-run-ai commentedon Dec 3, 2018
@lostmsu can you provide references for the new nuget package specs of platform definitions?
lostmsu commentedon Dec 3, 2018
@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
den-run-ai commentedon Dec 3, 2018
lostmsu commentedon Sep 24, 2021
This has been solved with the introduction of
clr_loaderfor Python andRuntime.PythonDLLfor .NET side.