tensorflow pip 和 conda 冲突

tensorflow pip and conda clash

我正在尝试将 tensorflow 1.8 安装到 1.10.1。不幸的是,我用 pip 和 conda 安装了它,当我尝试升级到 tensorflow 1.10.1 时它起作用了,但我收到以下错误消息。我试图用 pip 和 conda 删除它,并创建一个新的 conda 环境并在 conda 中重新安装它。没有安装其他版本的 tensorflow(也适用于任何其他 conda env)我 运行:

conda create -n testing python=3.6.5 scipy numpy jupyter scikit-learn matplotlib seaborn nltk tensorflow

然后,当我导入 tensorflow 时,我收到相同的错误消息:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
     57 
---> 58   from tensorflow.python.pywrap_tensorflow_internal import *
     59   from tensorflow.python.pywrap_tensorflow_internal import __version__

/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py in <module>()
     27             return _mod
---> 28     _pywrap_tensorflow_internal = swig_import_helper()
     29     del swig_import_helper

/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py in swig_import_helper()
     23             try:
---> 24                 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
     25             finally:

/anaconda3/envs/testing/lib/python3.6/imp.py in load_module(name, file, filename, details)
    242         else:
--> 243             return load_dynamic(name, filename, file)
    244     elif type_ == PKG_DIRECTORY:

/anaconda3/envs/testing/lib/python3.6/imp.py in load_dynamic(name, path, file)
    342             name=name, loader=loader, origin=path)
--> 343         return _load(spec)
    344 

ImportError: dlopen(/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: __ZN10tensorflow10DeviceBase16eigen_cpu_deviceEv
  Referenced from: /anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
  Expected in: /Users/avanders/tensorflow_libs/lib/libtensorflow_framework.so
 in /anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-2-64156d691fe5> in <module>()
----> 1 import tensorflow as tf

/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/__init__.py in <module>()
     20 
     21 # pylint: disable=g-bad-import-order
---> 22 from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
     23 
     24 try:

/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/__init__.py in <module>()
     47 import numpy as np
     48 
---> 49 from tensorflow.python import pywrap_tensorflow
     50 
     51 # Protocol buffers

/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py in <module>()
     72 for some common reasons and solutions.  Include the entire stack trace
     73 above this error message when asking for help.""" % traceback.format_exc()
---> 74   raise ImportError(msg)
     75 
     76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

ImportError: Traceback (most recent call last):
  File "/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/anaconda3/envs/testing/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/anaconda3/envs/testing/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: dlopen(/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: __ZN10tensorflow10DeviceBase16eigen_cpu_deviceEv
  Referenced from: /anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
  Expected in: /Users/avanders/tensorflow_libs/lib/libtensorflow_framework.so
 in /anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so


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.

原来问题出在我为 tensorflow 库安装的 go wrapper 的版本冲突。一旦我将这些包装器更新为相同版本,conda 安装就可以工作了。