简体   繁体   中英

Import tensorflow in Anaconda2: undefined symbol

This morning I am trying to install tensorflow on Anaconda3 (python version 3.5 & Ubuntu 16.04). I installed tensorflow with conda install tensorflow . However, it does not work well when importing it python/jupyter notebook.

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
>>> 

Have anyone encountered this before? I notice there are similar cases but the solution might not work with Anaconda3.

Install tensoflow pypi-package with pip

I had exactly the same error. The tensorflow version 1.0.0 was required for my application. There seems to be a difference between the conda-package and pypi-package of tensorflow. So uninstall the conda-package of tensorflow in <YOUR_CONDA_ENV> ironement and pip-install the pipy-package again:

# 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>

In your case <YOUR_CONDA_ENV>=tensorflow and the path to your conda environment location is <YOUR_CONDA_ENV_PATH>=/home/work/.conda/envs/tensorflow .

Make sure you use the pip install of your conda environment ( <YOUR_CONDA_ENV_PATH>/bin/pip ) and not the general pip ( /bin/pip ). If you haven't installed pip in your environment yet, just:

$ sudo conda install --name <YOUR_CONDA_ENV> pip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM