在老版本电脑上 安装完tensorflow后,在import tensorflow时出现如下错误:
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
新版本的 TensorFlow(1.6以上)会出现此问题,根据 TensorFlow 1.6.0 的发布说明,该版本会使用 AVX指令(可以通过CPU-Z软件查看CPU是否支持AVX 指令),所以可能会在旧 CPU 上不能运行:
Prebuilt binaries will use AVX instructions. This may break TF on older CPUs.
参考 Tensorflow 1.6.0 cpu fails on import on Windows 10 · Issue #17386 · tensorflow/tensorflow 的讨论,有两种解决办法:
- 使用旧版 TensorFlow,比如你可以使用
pip install tensorflow==1.5
来安装 1.5 版本,安装之前最好卸载 1.6 的。 - 使用 @fo40225 提供的重新编译好的版本。