0

The bug happens when I try to import Tensorflow on Eclipse. Tensorflow can be imported when I directly run the python code without using IDEs (I test it and it works perfectly). I've also tested my codes on PyCharm, it's fine with Pycharm....

I've tested the LD_LIBRARY_PATH,PATH,CUDA_HOME variables with echo. I also tried to directly append the cuda libraries into the Ecplipse pydev interpreter setting. So it is really confusing me. I did face a similar question with another machine, but I solved it by modifying the ~/.bashrc file.

I'm using Ubuntu16.04, python2.7,eclipse Neon3, GTX1080ti.

Any ideas? Following is the bug information:

Traceback (most recent call last): File "/home/zernmern/workspace/test/p1/test.py", line 2, in <module>

    import tensorflow as tf

  File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>

    from tensorflow.python import *
  File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>

    from tensorflow.python import pywrap_tensorflow
  File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>

    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>

    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>

    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/zernmern/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in 

    swig_import_helper_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)

ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

Failed to load the native TensorFlow runtime.

Please let me know if more information is needed xD.

Zern Mern
  • 1
  • 2
  • What did you do last time? Does that not work again? – JCooke Aug 01 '17 at 16:20
  • What I did with another machine is directly modifying the ~/.bashrc file by adding the "export PATH and LD_LIBRARY_PATH" codes into the file. But this time it doesn't work at all. xD. – Zern Mern Aug 01 '17 at 16:24
  • Is there an equivalent set of ENVs for Eclipse? – JCooke Aug 01 '17 at 16:25
  • I cannot be sure about it. Do you mean adding the variables into the 'environment' of the pydev interpreter setting? – Zern Mern Aug 01 '17 at 16:27
  • Possibly, I don't use Eclipse so I don't know. But if you say that Tensorflow loads correctly otherwise then it seems that your Eclipse is missing something. Does this help? https://stackoverflow.com/questions/43558707/tensorflow-importerror-libcusolver-so-8-0-cannot-open-shared-object-file-no – JCooke Aug 01 '17 at 16:29
  • I've read and try almost all the these similar questions....doesn't work for me this time xD – Zern Mern Aug 01 '17 at 16:31

2 Answers2

0

Ubuntu 16.04 uses Python 3.5 as the default system version of Python. You say that you are using Python 2.7. Did you install that yourself? It doesn't come with the OS. (And if you don't have a compelling reason to stay with Python 2.7, I would encourage you to switch to Py 3.x anyway, especially since you're working with a cutting-edge package like TensorFlow.)

Once you have two versions of Python on your system, it's easy to lose track of which packages you installed to which version of Python. I would check to see whether you happen to have installed TensorFlow, or parts of it, to the system Python 3.5 instead of your Python 2.7.

John Ladasky
  • 1,016
  • 8
  • 17
  • I've checked that I'm using python2.7, both default and with eclipse. I would take your suggestion and thinking about switch to python3 in future. – Zern Mern Aug 01 '17 at 19:57
  • And I tested with python3, it seems the problem is still not solved. I've just test my codes on PyCharm, it works well on it... So it should be some thing related to eclipse or pydev? – Zern Mern Aug 01 '17 at 20:44
  • Glad you were able to make something work, Zern. I found configuring Eclipse so that it would find the right folders to be painful, not just with TensorFlow, but with other applications. Eventually I settled for a more lightweight IDE. How badly do you need Eclipse to work? – John Ladasky Aug 10 '17 at 07:57
  • Actually not that necessary. So I switch to pyCharm Now xD – Zern Mern Aug 14 '17 at 21:22
0

Finally, I find the solution from 'PyCharm cannot find library' As the user 'Laizer' suggested:

The issue is that PyCharm(Here is Eclipse) was invoked from the desktop, and wasn't getting the right environment variables. Solution is to either:

invoke from the command line(i.e. Directly start eclipse by sh),
create a script to set environment and then invoke, and make a link to that script on the desktop,
or set environment variables on the desktop item
Zern Mern
  • 1
  • 2