问题描述
我的目标是将Python连接到.NET以进行处理.我正在使用IronPython.Python中的部分涉及一些计算,而我使用了Pandas库.
I aim to connect Python to .NET for a process. I am using IronPython for it.The part in Python involves some calculations for which I use the Pandas library.
有没有办法将IronPython和Pandas连接起来?
Is there a way to connect IronPython and Pandas?
我看到使用IronPython,我可以访问所有基本的Python功能.如何将其扩展到访问第三方功能/包(如此处的Pandas)?
I see using IronPython, I can access all the basic Python functionalities. How to extend this generally to access third party functionalities/packages (like Pandas here)?
推荐答案
简短答案:否.更长的答案:据我所知,tere无法以默认的python方式将C库与IronPython集成.由于pandas/numpy使用了大量的c代码,因此这是一个大麻烦.
Short answer: No.Longer answer: As far as I am aware tere is no way to integrate C-libraries with IronPython in the default python way. Since pandas / numpy use a heavy dose of c code, that is a showstopper.
我们使用 Python.net 进行此任务-基本上,我们在.NET中嵌入了python解释器并检索我们的计算结果.效果很好,避免了IronPython带来的问题.此外,托管" python进程是100%本机的,因此不会出现库问题.由于子流程是守护程序,因此子流程可能会出现一些问题,但是可以避免这些问题.
We use Python.net for this task - basically we embed an python interpreter in .NET and retrieve the results of our computations. That works well and avoids the problems which arise due to IronPython. Furthermore, the "hosted" python process is 100% native, so no library problems should arise.There can be some problems with subprocesses, since the process is a daemon, but they can be circumvented.
这篇关于使用IronPython访问Pandas库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!