无法在 Ubuntu 12.04 LTS 上正确安装或加载 Tensorflow,并导致 ImportError
Unable to properly install or load Tensorflow on Ubuntu 12.04 LTS with resultant ImportError
我在我的 Ubuntu 12.04 LTS 系统上尝试了 Anaconda installation for TensorFlow,它通过了,但是在 Python 中导入库时,我遇到了如下所示的 ImportError。
我查看了针对类似主题的 ,但它对我不起作用。
基本上这是我为安装所做的:
$ 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)
我该如何排序?
此错误可能与您的 glibc 版本有关。有一些关于此的主题:Where can I get a copy of the file 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" 可能不需要。
您需要安装 libstdc++6 以及一些依赖项,例如 gcc
和 g++
,至少 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-headers
和 build-essential
包含一些有用的工具,例如 gcc
编译器,make
.... 用于编译和从源代码构建软件。
它发生在我的 CentOS 7 中
运行 python conda 环境中的脚本我得到了关于 tensorflow 包装器所需的 "GLIBCXX_3.4.22..." 非常相似的错误。
在我的例子中,我首先做的是:
"conda install libgcc"
安装了一些库,但这对我没有帮助。我最终通过从先前安装的 Schroedinger maestro 软件附带的文件夹中删除 "GLIBCXX" 解决了这个问题。我认为,两个库之间存在某种冲突。
我在我的 Ubuntu 12.04 LTS 系统上尝试了 Anaconda installation for TensorFlow,它通过了,但是在 Python 中导入库时,我遇到了如下所示的 ImportError。
我查看了针对类似主题的
基本上这是我为安装所做的:
$ 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)
我该如何排序?
此错误可能与您的 glibc 版本有关。有一些关于此的主题:Where can I get a copy of the file 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" 可能不需要。
您需要安装 libstdc++6 以及一些依赖项,例如 gcc
和 g++
,至少 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-headers
和 build-essential
包含一些有用的工具,例如 gcc
编译器,make
.... 用于编译和从源代码构建软件。
它发生在我的 CentOS 7 中
运行 python conda 环境中的脚本我得到了关于 tensorflow 包装器所需的 "GLIBCXX_3.4.22..." 非常相似的错误。
在我的例子中,我首先做的是:
"conda install libgcc"
安装了一些库,但这对我没有帮助。我最终通过从先前安装的 Schroedinger maestro 软件附带的文件夹中删除 "GLIBCXX" 解决了这个问题。我认为,两个库之间存在某种冲突。