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
Python version: 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
Operating System: Windows and Linux
.NET Runtime: 8.0
Details
The Python my app calls has a number of dependencies. For predictability, I want to bundle the dependencies with my app, rather than obtain them via pip at runtime. I gathered the entire dependency tree, as well as the .py file with the code I plan to directly call, and added it all to my Visual Studio project, using build action "Content" and CopyToOutputDirectory=PreserveNewest for each item.
If I didn't need these dependencies, I would call:
PythonEngine.Initialize();
That works great. But since I do require the dependencies, I append their root folder to PythonPath first:
Simply appending libPath to PythonPath causes my app to crash on execution of PythonEngine.Initialize();
If there was a crash, please include the traceback here.
Is there a recommended way to obtain the traceback? The crash causes the app to exit immediately, there is no exception caught by the debugger. I am more than happy to gather any diagnostic info needed.
The text was updated successfully, but these errors were encountered:
By no means an expert, in fact been using this for a day lol
BUt this is what I did
privatevoidInitModules(){usingvarpy= Py.GIL();_sys= Py.Import(SysModuleName);if(_sys==null){
_logger.LogError($"Failed to import Python module: {SysModuleName}");return;}
_sys.path.append(Path.Combine(AppContext.BaseDirectory,"python"));_rtn= Py.Import(RtnModuleName);if(_rtn==null){
_logger.LogError($"Failed to import Python module: {RtnModuleName}");}}
```
Wherethe packages I have bundled are in a python folder that gets copied to output dir
Environment
Details
The Python my app calls has a number of dependencies. For predictability, I want to bundle the dependencies with my app, rather than obtain them via pip at runtime. I gathered the entire dependency tree, as well as the .py file with the code I plan to directly call, and added it all to my Visual Studio project, using build action "Content" and CopyToOutputDirectory=PreserveNewest for each item.
If I didn't need these dependencies, I would call:
That works great. But since I do require the dependencies, I append their root folder to PythonPath first:
Simply appending libPath to PythonPath causes my app to crash on execution of PythonEngine.Initialize();
Is there a recommended way to obtain the traceback? The crash causes the app to exit immediately, there is no exception caught by the debugger. I am more than happy to gather any diagnostic info needed.
The text was updated successfully, but these errors were encountered: