无法在Ubuntu16.04上使用Eclipse导入Tensorflow

时间:2017-08-01 16:12:43

标签: eclipse tensorflow ubuntu-16.04 pydev

当我尝试在Eclipse上导入Tensorflow时会发生错误。 Tensorflow可以  当我直接运行python代码而不使用IDE时导入(我测试它并且它完美地工作)。我还在PyCharm上测试了我的代码,对Pycharm来说很好....

我用echo测试了LD_LIBRARY_PATH,PATH,CUDA_HOME变量。我还尝试将cuda库直接附加到Ecplipse pydev解释器设置中。所以这让我很困惑。我确实遇到了与另一台机器类似的问题,但我通过修改〜/ .bashrc文件来解决它。

我正在使用Ubuntu16.04,python2.7,eclipse Neon3,GTX1080ti。

有什么想法吗?以下是错误信息:

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.

如果需要更多信息,请告诉我.x。

2 个答案:

答案 0 :(得分:0)

Ubuntu 16.04使用Python 3.5作为Python的默认系统版本。你说你使用的是Python 2.7。你自己安装了吗?它没有附带操作系统。 (如果你没有令人信服的理由继续使用Python 2.7,我会鼓励你切换到Py 3.x,特别是因为你正在使用像TensorFlow这样的尖端软件包。)

一旦你的系统上有两个版本的Python,就很容易忘记你安装哪个软件包到哪个版本的Python。我会检查你是否碰巧将TensorFlow或部分内容安装到系统Python 3.5而不是Python 2.7。

答案 1 :(得分:0)

最后,我找到了来自&#39; PyCharm cannot find library&#39;的解决方案。 作为用户&#39; Laizer&#39;提示:

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