python - 如何修复“无法加载原生 TensorFlow 运行时”错误
问题描述
我正在尝试使用 Powershell 从记事本中的文件运行我为 Tensorflow 编写的程序。每当我运行python main.py
打开并执行代码时,我都会收到以下错误。
我还没有真正找到任何可以尝试的东西,我觉得我唯一能做的就是卸载并重新安装 Tensorflow,但这不起作用。
C:\Users\stxrsstillfade> cd tensorflow-demo
C:\Users\stxrsstillfade\tensorflow-demo> python main.py
代码错误甚至与代码无关。回溯说问题出在第一行,import tensorflow
.
Traceback (most recent call last):
File "main.py", line 1, in <module>
import tensorflow as tf
File "C:\Python27\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Python27\lib\site-packages\tensorflow\python\__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Python27\lib\site-packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Python27\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow
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.
我已经尝试访问 GitHub 链接,但它似乎已被删除。
提前感谢您的回答。
解决方案
请按照TensorFlow 网站的说明进行操作。如果您使用的是较低版本,我建议您安装 Tensorflow 2 。
要修复此问题Failed to load the native TensorFlow runtime
,您需要从此处下载并安装/更新 Microsoft Visual C++ 2015-2019 Redistributable (x64) 。
如果您遇到任何其他问题,可能的原因是
- 您的 CPU 不支持 AVX2 指令
- 你的 CPU/Python 是 32 位的
- 有一个库位于不同的位置/未安装在您的系统上,无法加载。
推荐阅读
- android - 如何授予 TelephoneManager.class 权限以读取 Android-X86 中的文件
- php - 在 PHP 中:单引号比双引号更安全吗?
- sql - 删除 SQL 中列的重复值的行
- google-bigquery - BigQuery:--[no]use_avro_logical_types 标志不起作用
- java - Gradle 项目不在我的机器上构建,而是在其他人的机器上构建
- angular - 如何初始化变量值
- xslt-1.0 - 全局计数器 XSLT 1.0
- html - Google 登录按钮和辅助功能
- python - 将段落从印度地方语言音译为英语
- mysql - mysql:如何更快地插入具有许多索引的表中?