Closed rvetere closed 1 year ago
Look at the examples which download and install a custom python distribution instead of using the embedded one.
I tried to override the DownloadUrl like i have seen in the examples:
Python.Deployment.Installer.Source = new Python.Deployment.Installer.DownloadInstallationSource() { DownloadUrl = Environment.Is64BitProcess ? @"https://www.python.org/ftp/python/3.7.3/python-3.7.3-embed-amd64.zip" : @"https://www.python.org/ftp/python/3.7.3/python-3.7.3-embed-win32.zip", };
As soon as i start the app with x86 Platform, i get an error telling me
System.BadImageFormatException: "Could not load file or assembly 'Python.Runtime, Version=2.5.1.0, Culture=neutral, PublicKeyToken=null'.
I'm sure this is because somewhere the "amd64" image is hardcoded in Python.Included? But i don't know what would we need to update in the code of this package to make this work.
Did you find a solution? I tried the same thing like you, but the app crashes immediately when the module is loaded... doesn't even reach the 32/64 bit condition
Please download and compile the source code and try single stepping the loading routines. That way you can find out what happens and why things fail in your environment.
@rvetere @FrizzTheSnail
This is the cause of your troubles. This project is build with AMD64
as the architecture target. To target x86
you need to compile your own code.
MSB3270 There was a mismatch between the processor architecture of the project being built "x86" and the processor architecture of the reference "...\.nuget\packages\pythonnet_netstandard_py37_win\2.5.1\lib\netstandard2.0\Python.Runtime.dll", "AMD64". 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.
By default Python.Included includes the amd64 python binaries. If you want the x86 binaries you can use the Python.Deployment nuget to download those binaries as shown in the examples.
I tried to override the DownloadUrl like i have seen in the examples:
As soon as i start the app with x86 Platform, i get an error telling me
System.BadImageFormatException: "Could not load file or assembly 'Python.Runtime, Version=2.5.1.0, Culture=neutral, PublicKeyToken=null'.
I'm sure this is because somewhere the "amd64" image is hardcoded in Python.Included? But i don't know what would we need to update in the code of this package to make this work.