Skip to content

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

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

Closed
den-run-ai opened this issue May 25, 2017 · 16 comments
Closed

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

den-run-ai opened this issue May 25, 2017 · 16 comments
Labels
Milestone

Comments

@den-run-ai
Copy link
Contributor

den-run-ai commented May 25, 2017

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)

@den-run-ai
Copy link
Contributor Author

@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

@mphielipp
Copy link

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

@mphielipp
Copy link

.NET Framework 4.5.2

@mphielipp
Copy link

pythonnet_py35_dotnet 2.3.0

@den-run-ai
Copy link
Contributor Author

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
Copy link
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.

@STREETKILLER007
Copy link

STREETKILLER007 commented 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
Copy link
Contributor Author

den-run-ai commented Aug 14, 2018 via email

@filmor
Copy link
Member

filmor commented 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
Copy link
Member

lostmsu commented Dec 2, 2018

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

@filmor
Copy link
Member

filmor commented Dec 2, 2018

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

@lostmsu
Copy link
Member

lostmsu commented 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
Copy link
Contributor Author

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

@lostmsu
Copy link
Member

lostmsu commented 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
Copy link
Contributor Author

den-run-ai commented Dec 3, 2018 via email

@filmor filmor modified the milestones: 2.4.0, 2.5.0 Apr 12, 2019
@lostmsu lostmsu modified the milestones: 2.5.0, 3.0.0 Apr 23, 2020
@lostmsu
Copy link
Member

lostmsu commented Sep 24, 2021

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

@lostmsu lostmsu closed this as completed Sep 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants