我正在尝试使用
直接从源安装tensorflow git clone https://github.com/tensorflow/tensorflow
并遵循提供的构建轮子的教程。以下是我使用的命令的完整列表(已安装bazel):
git clone https://github.com/tensorflow/tensorflow
sudo pip3 install dev
sudo pip3 install numpy
sudo pip3 install wheel
./configure (at tensorflow source directory)
bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
sudo pip3 install /tmp/tensorflow_pkg/tensorflow-0.12.0rc0-cp35-none-any.whl
到目前为止,一切正常,并且轮盘文件似乎已成功安装为模块。但是,当我尝试在python3会话中导入tensorflow时,我收到了这个错误:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Symbol not found: _PyCObject_Type
Referenced from: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 60, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so, 10): Symbol not found: _PyCObject_Type
Referenced from: /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/tensorflow/python/_pywrap_tensorflow.so
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.
任何建议表示赞赏,谢谢!
答案 0 :(得分:2)
缺少的符号./configure
表明TensorFlow的C ++ Python扩展是针对与构建PIP包的Python不同版本的Python编译的。在bazel build
之前运行Please specify the location of python. [Default is /usr/bin/python]:
时,请确保回答以下提示:
python
...使用{{1}} 3.5可执行文件的正确路径。