我正在尝试从 R 调用我的 python 代码。这是我尝试过的简单代码。
import tensorflow as tf
a1=tf.constant(23)
b1=tf.constant(25)
s1=tf.Session()
with tf.Session() as s1:
out=s1.run(a1+b1)
print (out)
使用 rPython (R-library) 我尝试调用这个函数。
library(rPython)
# Load/run the main Python script
python.load("/Desktop/add.py")
但是为此发生了错误。
Error in python.exec(code, get.exception) :
Traceback (most recent call last):
File "/home/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
In addition: Warning message:
In readLines(file) :
incomplete final line found on '/Desktop/add.py'
但是我已经在 R 中安装了 tensorflow 作为install_tensorflow()。我找不到问题。有谁知道如何解决这个问题?