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
I have created a project using the new WinUI3 Template in Visual Studio 2022:
Trying to use Python.Included, I receive the following error in the debug output:
Exception thrown at 0x00007FFF99A34FD9 in WinUI3PythonIncluded.exe: Microsoft C++ exception: EEMessageException at memory location 0x000000DF2519D450.
Exception thrown: 'System.DllNotFoundException' in Python.Runtime.dll
Try if you can get pythonnet to work directly (Python.Included is just a deployment solution for pythonnet). See if it throws the same exception. That should give you more insights
When I run the program for the first time when the C:\Testing directory is empty, it will extract the zip file to the directory, and create the directory python-3.10.0-embed-amd64. However it crashes at this point and even manages to crash the Visual Studio Debugger. It also appears that something happened during extraction:
If I extract the contents of the zip file python-3.10.0-embed-amd64.zip into C:\Testing\python-3.10.0-embed-amd64 and run the program again, everything now works correctly:
VERSION: 3.10.0 (tags/v3.10.0:b494f59, Oct 4 2021, 19:00:18) [MSC v.1929 64 bit (AMD64)]
If I then run the WinUI3 project with Python.Included in it, after running the above project and letting it extract the zip file, everything works correctly.
Is there anything else you would like me to try or test?
Sorry, I have absolutely no idea. I've only been writing C# for about 2 months.
I also tried the following:
awaitTask.WhenAll(task);
Anything with the await seems to cause it to break.
Hope that helps.
One last thing I noticed when going through the code for the main branch, you haven't updated the download URL to 3.10.
In Python.Deployment -> Installer.cs:52:
I will try the updated package and let you know. I see that you only changed the version number of the python used, and nothing further has been done regarding this issue?
Yes I did not change anything else. Since this seems to be a problem with await in your app I see no reason to change SetupPython from async to blocking because you can call the SetupPython method blockingly yourself like this: SetupPython().Wait();
Where would be the difference between me calling Wait() inside of SetupPython and you calling it on your side? The effect should be the same. Please try and let me know.
Activity
henon commentedon May 24, 2022
Try if you can get pythonnet to work directly (Python.Included is just a deployment solution for pythonnet). See if it throws the same exception. That should give you more insights
onslauth commentedon May 24, 2022
Are you talking about
https://github.com/henon/pythonnet_netstandard
or
https://github.com/pythonnet/pythonnet ?
onslauth commentedon May 24, 2022
If I understand you correctly, I want to be looking at the following file:
https://github.com/henon/Python.Included/blob/master/Python.Included/Installer.cs
Is that correct?
henon commentedon May 24, 2022
yes I am talking about https://github.com/pythonnet/pythonnet
see if it works with WinUI3
henon commentedon May 24, 2022
Only if we assume that the deployment didn't work. But there is no indication of that yet.
onslauth commentedon May 24, 2022
I have installed the embedded python to the folder
C:\Python\I have also created a new WinUI3 template program to test the code and tested both inside a task and without:
and
They both fail to run with the following errors respectively:
I expect I need to take this up further with the pythonnet developers?
henon commentedon May 24, 2022
Yes. Please post the link to issue you are about to create on their github here so other people with similar issues can follow.
onslauth commentedon May 24, 2022
pythonnet/pythonnet#1796
Thank you for the help.
onslauth commentedon May 24, 2022
With help from the Pythonnet developers, the program now runs.
The solution can be found here: https://github.com/onslauth/WinUI3-Pythonnet
Is there something else you would like me to try with regards to getting Python.Included working?
onslauth commentedon May 24, 2022
I've had some time to play around now.
I updated the nuget package to:
3.10.0-preview1so that I can directly set thePythonDLLproperty.During
Installer.SetupPython( )it seems to crash or hang or something in this step breaks.I changed my code to the following:
When I run the program for the first time when the
C:\Testingdirectory is empty, it will extract the zip file to the directory, and create the directorypython-3.10.0-embed-amd64. However it crashes at this point and even manages to crash the Visual Studio Debugger. It also appears that something happened during extraction:If I extract the contents of the zip file
python-3.10.0-embed-amd64.zipintoC:\Testing\python-3.10.0-embed-amd64and run the program again, everything now works correctly:henon commentedon May 25, 2022
If I were you I would check out the code of SetupPython and single step it in debugger to see exactly which line crashes.
onslauth commentedon May 25, 2022
Hi,
I have managed to track the problem down to line 92 in
Python.DeploymentInstaller.cs, specifically this line:Even though the code is in a try/catch section, it seems to bypass that.
I have also tested the above code in a new WinUI 3 Template project, and everything works fine without issue:
If I then run the WinUI3 project with
Python.Includedin it, after running the above project and letting it extract the zip file, everything works correctly.Is there anything else you would like me to try or test?
henon commentedon May 25, 2022
I have no idea why the same line of code works in your app but not when called via the nuget or link the python included code base.
onslauth commentedon May 25, 2022
Hi @henon
I have had some time to play with the code, and found a solution for you.
The following seems to work without problems:
Please let me know if you require any further testing from me.
henon commentedon May 25, 2022
Can you explain why your change works?
onslauth commentedon May 25, 2022
Sorry, I have absolutely no idea. I've only been writing C# for about 2 months.
I also tried the following:
Anything with the
awaitseems to cause it to break.Hope that helps.
One last thing I noticed when going through the code for the
mainbranch, you haven't updated the download URL to 3.10.In
Python.Deployment -> Installer.cs:52:Thank you for all the help.
henon commentedon May 26, 2022
and what if you call
SetupPython().Wait();? wouldn't that work?henon commentedon May 31, 2022
by the way, there is a preview package including python 3.10: https://www.nuget.org/packages/Python.Included/3.10.0-preview2
onslauth commentedon Jun 15, 2022
Hi,
Sorry, I've been a bit busy.
I will try the updated package and let you know. I see that you only changed the version number of the python used, and nothing further has been done regarding this issue?
henon commentedon Jun 15, 2022
Yes I did not change anything else. Since this seems to be a problem with
awaitin your app I see no reason to changeSetupPythonfrom async to blocking because you can call theSetupPythonmethod blockingly yourself like this:SetupPython().Wait();Where would be the difference between me calling
Wait()inside ofSetupPythonand you calling it on your side? The effect should be the same. Please try and let me know.