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 am trying to use Python.NET to perform interop between C# and Python on a Windows machine.
Specifically I have the following code.
PythonEngine.PythonHome = @"C:\Python\3_5_4";
PythonEngine.PythonPath = @"C:\Python\3_5_4\Lib;C:\Python\3_5_4\Lib\site-packages";
using (Python.Runtime.Py.GIL())
{
dynamic np = Py.Import("numpy");
dynamic sin = np.sin;
Console.WriteLine(sin);
}
While I can successfully execute a general python statement as such:
var res = PythonEngine.Eval("1 + 1");
Console.WriteLine(res);
//res = 2
Which indicates that the python engine itself is working successfully, I can also invoke something like this:
var html = Py.Import("html");
Console.WriteLine(html);
//html = <module 'html' from 'C:\\Python\\3_5_4\\Lib\\html\\__init__.py'>
Which further indicates that the module loading functionality is also working correctly.
However whenever I attempt to invoke the line:
dynamic np = Py.Import("numpy");
I receive the following error:
{"ImportError : No module named '_ctypes'"}.
[' File "C:\\Python\\3_5_4\\Lib\\site-packages\\numpy\\__init__.py", line 140, in <module>\n from . import _distributor_init\n', ' File "C:\\Python\\3_5_4\\Lib\\site-packages\\numpy\\_distributor_init.py", line 9, in <module>\n from ctypes import WinDLL\n', ' File "C:\\Python\\3_5_4\\Lib\\ctypes\\__init__.py", line 8, in <module>\n from _ctypes import Union, Structure, Array\n']
The file referenced is located @ C:\Python\3_5_4\Lib\ctypes\__init__.py.
I have verified that all the expected paths are set correctly and that the Ctypes folder exists in my python path.
I have tried everything from uninstalling and reinstalling Python to modifying the ctypes/__init__.py file to try and import Ctypes directly to no effect.
Having researched this topic online throughly I have found a number of suggestions which point to running yum install libffi-develas detailed here. However this does not appear to be something that I can perform on windows given that yum appears to be a Linux only application.
Can anyone provide any guidance?
The text was updated successfully, but these errors were encountered:
@MaximG1234 : _ctypes.pyd is in PYTHONHOME/DLLs. You should include the directory in your PYTHONPATH environment variable. I can confirm that it will work as I already tried it by myself.
Environment
I am trying to use Python.NET to perform interop between C# and Python on a Windows machine.
Specifically I have the following code.
While I can successfully execute a general python statement as such:
Which indicates that the python engine itself is working successfully, I can also invoke something like this:
Which further indicates that the module loading functionality is also working correctly.
However whenever I attempt to invoke the line:
I receive the following error:
{"ImportError : No module named '_ctypes'"}
.The file referenced is located @
C:\Python\3_5_4\Lib\ctypes\__init__.py
.I have verified that all the expected paths are set correctly and that the Ctypes folder exists in my python path.
I have tried everything from uninstalling and reinstalling Python to modifying the
ctypes/__init__.py
file to try and import Ctypes directly to no effect.Having researched this topic online throughly I have found a number of suggestions which point to running
yum install libffi-devel
as detailed here. However this does not appear to be something that I can perform on windows given that yum appears to be a Linux only application.Can anyone provide any guidance?
The text was updated successfully, but these errors were encountered: