[英]Cannot install Tensorflow on Ubuntu Linux
System Information系统信息
MacBook Air M1 MacBook Air M1
Ubuntu Linux 20.04 using virtual machine Ubuntu Linux 20.04 使用虚拟机
Python 3.8.5 64 bits Python 3.8.5 64 位
I have already installed tensor flow but after importing the library and compiling any code it gives me the following set of error我已经安装了张量流,但在导入库并编译任何代码后,它给了我以下一组错误
Traceback (most recent call last):
File "/home/mradulagrawal/Desktop/IP/image.py", line 2, in <module>
import tensorflow
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/usr/lib/python3.8/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.8/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow.so: invalid ELF header
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
mradulagrawal@ubuntu:~/Desktop$ /usr/bin/python3 /home/mradulagrawal/Desktop/IP/image.py
Traceback (most recent call last):
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/usr/lib/python3.8/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.8/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow.so: invalid ELF header
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/mradulagrawal/Desktop/IP/image.py", line 2, in <module>
import tensorflow
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/usr/lib/python3.8/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.8/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/mradulagrawal/.local/lib/python3.8/site-packages/tensorflow/python/_pywrap_tensorflow.so: invalid ELF header
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Thank You!谢谢你!
According to the information you provided, the problem occurred in the relevant files of the installed module "tensorflow".根据您提供的信息,问题出在安装的“tensorflow”模块的相关文件中。
It is recommended that you find the installation package folder of the module "tensorflow" in this python environment and try to delete it, then reinstall it to avoid damage or incompatibility of some files.建议大家在这个python环境中找到“tensorflow”模块的安装文件夹package尝试删除,然后重新安装,避免部分文件损坏或不兼容。
We can use " pip show module
" to find the installation location of the module:我们可以通过“ pip show module
”找到模块的安装位置:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.