How to call scala from python?

青春壹個敷衍的年華 提交于 2021-01-27 12:52:53

问题


I would like to build my project in Scala and then use it in a script in Python for my data hacking (as a module or something like that). I have seen that there are ways to integrate python code into JVM languages with Jython (only Python 2 projects though). What I want to do is the other way around though. I found no information on the net how to do this, but it seems strange that this should not be possible.


回答1:


General solution -- use some RPC/IPC (sockets, protobuf, whatever).

However, you might want to look at Spark's solution -- how they translate Python code in Scala's APIs (https://www.py4j.org/) .




回答2:


Recently, scalapy was created to call Python libraries from Scala.

https://github.com/shadaj/scalapy



来源:https://stackoverflow.com/questions/39530375/how-to-call-scala-from-python

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