无法在Ubuntu 12.04 LTS上正确安装或加载Tensorflow并导致导致错误

我尝试了我的Ubuntu 12.04 LTS系统上的TensorFlow的Anaconda安装 ,但是在Python导入库时,我遇到了下面显示的ImportError。

我经历了类似的线程给出的解决scheme ,但它并没有为我工作。

基本上这是我为安装做的:

$ conda create -n tensorflow python=2.7 $ source activate tensorflow (tensorflow)$ conda install -c conda-forge tensorflow (tensorflow)$ source deactivate $ source activate tensorflow 

然后从virtualenv我加载Python,并试图导入tensorflow。 我得到的是以下错误:

 >>> import tensorflow Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/anirudh/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module> from tensorflow.python import * File "/home/anirudh/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 48, in <module> from tensorflow.python import pywrap_tensorflow File "/home/anirudh/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module> _pywrap_tensorflow = swig_import_helper() File "/home/anirudh/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description) ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.19' not found (required by /home/anirudh/anaconda/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so) 

我如何分类?

你需要安装libstdc ++ 6 ,像gccg++这样的依赖,至少gcc-4.6版本:

 sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update sudo apt-get install gcc-4.9 g++-4.9 sudo apt-get install libstdc++6 

或者你可以安装linux-headersbuild-essential巫婆包含一些有用的工具,如gcc编译器, make ….工具编译和从源代码构建软件。

这个错误可能与你的glibc版本有关。 有一些关于这方面的话题: 我在哪里可以得到libstdc ++。so.6.0.15文件的副本

首先检查所需版本是否在您的系统上。

  $ strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXX 

如果没有列出,你可以试试

  $ sudo add-apt-repository ppa:ubuntu-toolchain-r/test $ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get dist-upgrade 

“sudo apt-get dist-upgrade”可能不是必需的。