TensorFlow 2.1.0安装成功,但TensorFlow导入失败。
未决问题:
是否有一个库位于其他位置/未安装在无法加载的系统上?
复制程序:
1( 创建环境
conda create --name tensorflow21_env
2( 激活环境
conda activate tensorflow21_env
3( 安装
conda install python=3.7
pip install tensorflow-cpu #install tensorflow=2.1.0;
4(测试
python -c "import tensorflow as tf"
堆栈跟踪:
Traceback (most recent call last):
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow_corepythonpywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow_corepythonpywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow_corepythonpywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:Anaconda3envstensorflow21_envlibimp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:Anaconda3envstensorflow21_envlibimp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow__init__.py", line 101, in <module>
from tensorflow_core import *
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow_core__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow__init__.py", line 50, in __getattr__
module = self._load()
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "C:Anaconda3envstensorflow21_envlibimportlib__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow_corepython__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow_corepythonpywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow_corepythonpywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow_corepythonpywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:Anaconda3envstensorflow21_envlibsite-packagestensorflow_corepythonpywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:Anaconda3envstensorflow21_envlibimp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:Anaconda3envstensorflow21_envlibimp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
安装输出:
输出:conda-install-python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: C:Anaconda3envstensorflow21_env
added / updated specs:
- python=3.7
The following NEW packages will be INSTALLED:
ca-certificates pkgs/main/win-64::ca-certificates-2020.1.1-0
certifi pkgs/main/win-64::certifi-2019.11.28-py37_0
openssl pkgs/main/win-64::openssl-1.1.1d-he774522_4
pip pkgs/main/win-64::pip-20.0.2-py37_1
python pkgs/main/win-64::python-3.7.6-h60c2a47_2
setuptools pkgs/main/win-64::setuptools-45.2.0-py37_0
sqlite pkgs/main/win-64::sqlite-3.31.1-he774522_0
vc pkgs/main/win-64::vc-14.1-h0510ff6_4
vs2015_runtime pkgs/main/win-64::vs2015_runtime-14.16.27012-hf0eaf9b_1
wheel pkgs/main/win-64::wheel-0.34.2-py37_0
wincertstore pkgs/main/win-64::wincertstore-0.2-py37_0
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
依赖项助行器确认可以加载所有DLL(下载依赖项助行者(。
dependency_trace
加载项:依赖助行器的路径
C:Anaconda3envstensorflow21_envLibsite-packagestensorflow_corepython_pywrap_tensorflow_internal.pyd
更新:
我的处理器既不支持AVX也不支持AVX2,因此无法安装tensorflow pip包,或者更准确地说,无法导入tensorflow包。
临时解决方案:
遗留问题的临时解决方案;不支持AVX的低端CPU是为tensorflow安装SSE预构建二进制文件。转到tensorflow windows轮子并按照说明安装tensorflow 2.0.0或2.1.0。
尝试此方法:
卸载您使用pip安装的TensorFlow包,然后使用conda-install TensorFlow重新安装,这可能有效!现在,您可以毫无问题地导入TensorFlow。我希望这能帮助你。
如果您需要更详细的步骤。在这里,你可以做以下操作
-
以管理员身份运行anaconda提示符。(右键单击->以管理员身份运行(。
-
pip uninstall tensorflow
-
关闭anaconda提示符。
-
再次以管理员身份运行anaconda提示符。
-
类型:
conda install tensorflow
它会要求一些y / n
键入y
。
现在,完成所有操作后,将python解释器的环境更改为安装tensorflow的anaconda环境。
- 现在尝试导入tensorflow
我希望这能有所帮助。