在php代码中运行使用tensorflow的python代码时出错。错误是: -
Traceback (most recent call last):
File "Loader.py", line 5, in import tensorflow as tf
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 48, in from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in _pywrap_tensorflow = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: /usr/local/lib/python2.7/dist-packages/tensorflow/python/_pywrap_tensorflow.so: invalid ELF header
尝试执行python代码的几行Python代码是: -
$temp = shell_exec('python Loader.py 2>&1') or die('cannot run Loader.py') ;
echo $temp;
答案 0 :(得分:0)
创建新的虚拟环境。安装依赖项,然后运行代码。