首页 > 解决方案 > 无法导入 TensorFlow v1.12

问题描述

我在 Python 3.6.7 上安装了 Tensorflow 1.12,使用:

conda install tensorflow-gpu

使用支持 AVX 和 AVX2 的 CPU 运行 Windows Server 2016。导入 tensorflow 时得到以下信息:

 import tensorflow as tf

ImportError Traceback (最近一次调用最后) ~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in 57 ---> 58 from tensorflow.python.pywrap_tensorflow_internal import * 59 from tensorflow.python.pywrap_tensorflow_internal 导入版本

~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in 27 return _mod ---> 28 _pywrap_tensorflow_internal = swig_import_helper() 29 del swig_import_helper

~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper() 23 try: ---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) 25 最后:

~\Anaconda3\lib\imp.py in load_module(name, file, filename, details) 242 else: --> 243 return load_dynamic(name, filename, file) 244 elif type_ == PKG_DIRECTORY:

~\Anaconda3\lib\imp.py in load_dynamic(name, path, file) 342 name=name, loader=loader, origin=path) --> 343 return _load(spec) 344

ImportError:DLL 加载失败:找不到指定的模块。

在处理上述异常的过程中,又出现了一个异常:

ImportError Traceback (last last call last) in ----> 1 import tensorflow as tf

~\Anaconda3\lib\site-packages\tensorflow__init__.py in 22 23 # pylint: disable=g-bad-import-order ---> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import 25 26 试试:

~\Anaconda3\lib\site-packages\tensorflow\python__init__.py in 47 import numpy as np 48 ---> 49 from tensorflow.python import pywrap_tensorflow 50 51 from tensorflow.python.tools import component_api_helper

~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py 72 中的一些常见原因和解决方法。寻求帮助时,在此错误消息上方包含整个堆栈跟踪 73。""" % traceback.format_exc() ---> 74 raise ImportError(msg) 75 76 # pylint: enable=wildcard-import,g-import-not -在顶部,未使用的导入,行太长

ImportError: Traceback (最近一次调用最后一次): File "C:\Users\tkassis\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",第 58 行,来自 tensorflow.python.pywrap_tensorflow_internal import * File" C:\Users\tkassis\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py”,第 28 行,在 _pywrap_tensorflow_internal = swig_import_helper() 文件“C:\Users\tkassis\Anaconda3\lib\site-packages\ tensorflow\python\pywrap_tensorflow_internal.py”,第 24 行,在 swig_import_helper _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description) 文件“C:\Users\tkassis\Anaconda3\lib\imp.py”,第 243 行, 在 load_module 返回 load_dynamic(name, filename, file) 文件“C:\Users\tkassis\Anaconda3\lib\imp.py”,第 343 行,在 load_dynamic return _load(spec) ImportError: DLL load failed: 找不到指定的模块。

标签: pythonpython-3.xtensorflow

解决方案


推荐阅读