Python code inside c#
Team , we have some python code which need to be run inside c# . There is link to that in https://github.com/pythonnet/pythonnet#embedding-python-in-net but when i tried,it is giving error as Runtime.PythonDLL was not set . Does anyone know how to handle this ?
GitHub
GitHub - pythonnet/pythonnet: Python for .NET is a package that giv...
Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET develo...
15 Replies
well, without seeing any code we can only say set it appropriately
$code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
For longer snippets, use: https://paste.mod.gg/how do i format this?
like that
I think it went as a file..It got formatted but coundnt send
if u have the constant path u can also just set the property directly
but generally speaking, u didnt really read what u linked to right?
i mean, it literally says in the first point that the environment variable for the path to the dll is called
PYTHONNET_PYDLL
, but u r modifying the PATH
env var
and u r missing the PythonEngine.Initialize();
call as wellI tried PythonEngine.Initialize(); but got the same error..
using (Py.GIL()) now this is giving 'Attempted to read or write protected memory. This is often an indication that other memory is corrupt.'
well, u have to set the dll path correctly and call
PythonEngine.Initialize();
according to their docsOk got that now ... this worked ..thanks @cap5lut 🙂
last thing
u couldve saved urself some struggle by reading what u linked (thats what i did because i never used that library ;p)
Python.Runtime.PythonException: 'No module named 'spacy''
should i download this spacy library to local ?
Yes sometimes I overlook and trying out different unwanted things
i have next to no clue about python and absolutely no clue how that library works
Even I am not into python ... so all this is new to me... 😄
let me figure out . thanks for sorting out the main problem 🙂
from brief reading and some foggy memories:
basically u need to setup the virtual environment for the python stuff.
that library seems to not download modules for u so u have to set up this stuff urself
OK ok ...got it