我想知道在jython会话中导入Tensorflow是否可行,如果是,我该如何配置环境以使其运行。
当然,使用python,导入Tensorflow按预期工作。 Tensorflow与Jython兼容吗?
[matacheck] /home/ghodbane/mlp > python
imPython 2.7.12 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:42:40) [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import tensorflow as tf
>>>
而Jython
[matacheck] /home/ghodbane/mlp > jython
Jython 2.7.0 (default:9987c746f838, Apr 29 2015, 02:25:11)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_101
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
>>>
更新: 我试图加载libtensorflow JAR但是,我似乎在这里遗漏了一些东西......
>>> import sys
>>> sys.path.append("libtensorflow-1.2.1.jar")
>>> help(tf) # OK
但我必须错过一些显而易见的步骤才能让你的Tensorflow案例工作......
答案 0 :(得分:0)
不,Jython不适用于使用C / C ++的Python模块。
您尝试使用的jar是针对Java API(通过JNI),所以猜猜您已经看过https://www.tensorflow.org/install/install_java