今天早上,我正在尝试在Anaconda3(python版本3.5和Ubuntu 16.04)上安装tensorflow。我用conda install tensorflow
安装了tensorflow。但是,将其导入python / jupyter笔记本时效果不佳。
Python 3.5.6 |Anaconda, Inc.| (default, Aug 26 2018, 21:41:56)
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/work/.conda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/home/work/.conda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/home/work/.conda/envs/tensorflow/lib/python3.5/site-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "/home/work/.conda/envs/tensorflow/lib/python3.5/site-packages/google/protobuf/descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: /home/work/.conda/envs/tensorflow/lib/python3.5/site-packages/google/protobuf/pyext/_message.cpython-35m-x86_64-linux-gnu.so: undefined symbol: _ZNK6google8protobuf10TextFormat17FieldValuePrinter9PrintBoolEb
>>>
以前有人遇到过吗?我注意到也有类似的情况,但是该解决方案可能不适用于Anaconda3。
答案 0 :(得分:0)
我有完全相同的错误。我的应用程序需要tensorflow版本1.0.0。张量流的conda包和pypi包之间似乎有所不同。因此,请在<YOUR_CONDA_ENV>
固件中卸载tensorflow的conda程序包,然后再次pip安装pipy程序包:
# uninstall current tensorflow conda-package
$ sudo conda uninstall --name <YOUR_CONDA_ENV> tensorflow
# install the pypi-package of tensorflow
$ sudo <YOUR_CONDA_ENV_PATH>/bin/pip install tensorflow==<REQUIRED_VERSION>
在您的情况下,<YOUR_CONDA_ENV>=tensorflow
到conda环境位置的路径为<YOUR_CONDA_ENV_PATH>=/home/work/.conda/envs/tensorflow
。
确保使用conda环境(pip install
)的<YOUR_CONDA_ENV_PATH>/bin/pip
,而不是常规点(/bin/pip
)。如果您尚未在环境中安装pip,请执行以下操作:
$ sudo conda install --name <YOUR_CONDA_ENV> pip