简体   繁体   English

python Tensorflow 导入错误

[英]python Tensorflow ImportError

Please help me with this error:请帮我解决这个错误:

import tensorflow as tf Traceback (most recent call last): File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in from tensorflow.python.pywrap_tensorflow_internal import * File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "/home/user/anaconda3/lib/python3.6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/home/user/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic return _load(spec) ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory import tensorflow as tf Traceback(最近一次调用):文件“/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py”,第41行,来自tensorflow.python.pywrap_tensorflow_internal导入 * 文件“/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”,第 28 行,在 _pywrap_tensorflow_internal = swig_import_helper() 文件“/home/user/anaconda3/lib/ python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) File "/home/user/anaconda3/lib/python3 .6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/home/user/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic return _load(规范)导入错误:libcusolver.so.8.0:无法打开共享对象文件:没有这样的文件或目录

During handling of the above exception, another exception occurred:在处理上述异常的过程中,又发生了一个异常:

Traceback (most recent call last): File "", line 1, in File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/ init .py", line 24, in from tensorflow.python import * File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/ init .py", line 49, in from tensorflow.python import pywrap_tensorflow File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in raise ImportError(msg) ImportError: Traceback (most recent call last): File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in from tensorflow.python.pywrap_tensorflow_internal import * File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in _pywrap_tensorflow_internal = swig_import_helper() File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper _mod = imp.load_module('_pyw回溯(最近通话最后一个):文件“”,1号线,在文件“/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/初始化的.py”,第24行,从tensorflow.python进口*文件“/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/初始化py”为49行,从tensorflow.python进口pywrap_tensorflow文件“/ home / user中/ anaconda3 / lib目录/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in raise ImportError(msg) ImportError: Traceback (last last call last): File "/home/user/anaconda3/lib/python3. 6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in from tensorflow.python.pywrap_tensorflow_internal import * File "/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/ pywrap_tensorflow_internal.py”,第 28 行,在 _pywrap_tensorflow_internal = swig_import_helper() 文件“/home/user/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py”,第 24 行,在 swig_import_moder 中.load_module('_pyw rap_tensorflow_internal', fp, pathname, description) File "/home/user/anaconda3/lib/python3.6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/home/user/anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic return _load(spec) ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory rap_tensorflow_internal', fp, pathname, description) File "/home/user/anaconda3/lib/python3.6/imp.py", line 243, in load_module return load_dynamic(name, filename, file) File "/home/user/ anaconda3/lib/python3.6/imp.py", line 343, in load_dynamic return _load(spec) ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

Failed to load the native TensorFlow runtime.无法加载本机 TensorFlow 运行时。

See https://www.tensorflow.org/install/install_sources#common_installation_problems请参阅https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.出于一些常见的原因和解决方案。 Include the entire stack trace above this error message when asking for help.寻求帮助时,请在此错误消息上方包含整个堆栈跟踪。

You could try that:你可以试试:

  1. Confirm the python interpreter path, is anaconda or system python?确认python解释器路径,是anaconda还是system python?

  2. export python library export PYTHONPATH=xxxxx:$PYTHONPATH to solve some lib couldn't find before execute a python script in terminal. export python library export PYTHONPATH=xxxxx:$PYTHONPATH解决在终端执行python脚本之前找不到的一些lib。

If you following two step, above troubles could be solved.如果您遵循两个步骤,则可以解决上述问题。

Before importing TensorFlow, you need to install TensorFlow on Python 3.6.在导入 TensorFlow 之前,您需要在 Python 3.6 上安装 TensorFlow。 Firstly, I assumed that you use the Windows operating system because you did not explain any information about your computer.首先,我假设您使用的是 Windows 操作系统,因为您没有解释有关您计算机的任何信息。 Open the Anaconda prompt, install TensorFlow with this command:打开 Anaconda 提示符,使用以下命令安装 TensorFlow:

pip install tensorflow==2.0

If everything installs successfully, you can import the TensorFlow library in Python.如果一切安装成功,您可以在 Python 中导入 TensorFlow 库。

import tensorflow as tf 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM