我怎么得到Python.NET使用Python3.6?我复制了下面的示例代码,当我运行它时,我得到了错误:
Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'python35': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at Python.Runtime.Runtime.Py_IsInitialized()
at Python.Runtime.Runtime.Initialize()
at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv)
at Python.Runtime.PythonEngine.Initialize(Boolean setSysArgv)
at Python.Runtime.PythonEngine.Initialize()
at Python.Runtime.Py.GIL()
我没有python3.5,因此没有python35.dll。我有python3.6。这是水蟒分布的一部分。我怎么得到Python.Net用这个?在
示例代码:
^{pr2}$更新以回答评论中的问题: 我安装了Python.net通过获得NuGet包“pythonnet_py35_dotnet”,它的版本是v2.3.0。在
python-c“导入系统;打印(系统版本)“给予
3.6.0 |Anaconda custom (64-bit)| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)]
“python”给出了
C:\Users\<username>\AppData\Local\Continuum\Anaconda3\python.exe
我的解决方案是:
*假设我使用的是Visual Studio 2012学习版
Python.Runtime.dll
的引用(如果很难轻松找到DLL文件,只需尝试在windows上使用Everything应用程序)在C代码的顶部添加以下行。在
在调用
using (Py.GIL()){...}
之前添加以下代码最后,最重要的是在Properties is Solution Explorer的Build选项卡中设置系统架构类型。
在我的例子中(不使用虚拟环境),如下图:
希望它能起作用!在
相关问题 更多 >
编程相关推荐