3

I attempted the Anaconda installation for TensorFlow on my Ubuntu 12.04 LTS system, which went through, but while importing the library in Python, I came across an ImportError shown below.

I went through a solution given for a similar thread, but it didn't work for me.

Basically here's what I did for the installation:

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

Then from within the virtualenv I loaded Python, and tried to import tensorflow. What I got was the following error:

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

How do I sort this?

Community
  • 1
  • 1
Anirudh
  • 121
  • 1
  • 8

3 Answers3

0

This error probably relates to you glibc version. There are some topics regarding this:Where can I get a copy of the file libstdc++.so.6.0.15

First check whether the required version is on your system.

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

If it is not listed, you can try

    $ 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" may not be required.

Community
  • 1
  • 1
Young
  • 254
  • 1
  • 3
  • 10
0

You need to install libstdc++6 with some dependencies like gcc an g++, at least gcc-4.6 version:

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

Or you can install linux-headers and build-essential witch contains some useful tools like gcc compiler, make .... tools for compiling and building software from source.

GAD3R
  • 4,317
  • 1
  • 23
  • 34
0

It happened for me in CentOS 7

Running python script in conda environment I got very similar error about "GLIBCXX_3.4.22..." required by tensorflow wrapper.

In my case first I did was:

"conda install libgcc"

Some libraries were installed, but that didn't helped me. I finally solved the issue by deleting "GLIBCXX" from the folder that came with Schroedinger maestro software that was installed earlier. I think, there was some sort of conflict between two libraries.

farynaa
  • 330
  • 3
  • 7