Import scikit in C# application

廉价感情. 提交于 2020-01-01 19:11:09

问题


I am trying to import scikit-learn in a C# (console) application. I am using Python Tools for Visual Studio and IronPython 2.7.3.

I managed to run an external python script and I also managed to import numpy by declaring the python path: "C:\Python27\Lib\site-packages\"

However, when it comes to scikit-learn I get an error message:

Oops! We couldn't execute the script because of an exception: No module named _c
heck_build
___________________________________________________________________________
Contents of C:\Python27\Lib\site-packages\sklearn\__check_build:
setup.py                  setup.pyc                 setup.pyo
_check_build.pyd          __init__.py               __init__.pyc
__init__.pyo
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.

If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.

If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.

The file "_check_build.pyd" exists in "C:\Python27\Lib\site-packages\sklearn__check_build\".

My code is based on this article: http://devleader.ca/2013/09/23/visual-studio-c-python-sweet/ The file I am using has only the following code:

from sklearn.svm import SVC

print('Hello Python in C#')

Is it possible to add and use scikit in C#? If yes, could you please provide a workaround?


回答1:


Looks like scikit-learn requires a C extension, which means it won't run under IronPython.



来源:https://stackoverflow.com/questions/20036793/import-scikit-in-c-sharp-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!