gpt4 book ai didi

python - 安装和运行 Tensorflow 时出现 ValueError

转载 作者:行者123 更新时间:2023-12-04 00:53:15 25 4
gpt4 key购买 nike

为了了解深度学习和神经网络,我尝试在我的笔记本电脑(Dell Inspiron 5559、4GB RAM、Windows 10)上安装 Tensorflow,使用 conda 4.9.1(最初包含 Python 3.8.3)。为此,我使用了以下命令:

conda create -n tf tensorflow

这成功运行并安装了 Python 3.7.9tensorflow 2.1.0 和许多其他模块。现在我想测试它是否有效,所以在 Python 终端中,导入了一些模块。 mathnumpy 导入成功。但是当我导入 tensorflow 时,该过程失败并显示以下内容:

>>> import tensorflow      

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\Program Files\Anaconda3\envs\tf\lib\site-packages\tensorflow\__init__.py", line 101, in
<module> from tensorflow_core import *
File "D:\Program Files\Anaconda3\envs\tf\lib\site-packages\tensorflow_core\__init__.py", line 40, in
<module> from tensorflow.python.tools import module_util as _module_util
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 959, in _find_and_load_unlocked
File "D:\Program Files\Anaconda3\envs\tf\lib\site-packages\tensorflow\__init__.py", line 50, in
__getattr__ module = self._load()
File "D:\Program Files\Anaconda3\envs\tf\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "D:\Program Files\Anaconda3\envs\tf\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "D:\Program Files\Anaconda3\envs\tf\lib\site-packages\tensorflow_core\python\__init__.py", line
49, in <module> from tensorflow.python import pywrap_tensorflow
File "D:\Program Files\Anaconda3\envs\tf\lib\site-
packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\Program Files\Anaconda3\envs\tf\lib\site-
packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Program Files\Anaconda3\envs\tf\lib\site-
packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 15, in swig_import_helper
import imp
ValueError: source code string cannot contain null bytes

即使我运行导入 Tensorflow 的程序也会出现此错误。

我检查了大多数其他教程,似乎没有人遇到过这个错误。我也尝试使用较低版本的 Python 和 Tensorflow,但出现了同样的错误。

谁能找到正在发生的事情,我应该怎么做?

最佳答案

我发现使用不是3.6.X的python版本安装和导入tensorflow有时非常困难,我推荐使用python 3.6.X,它更容易

关于python - 安装和运行 Tensorflow 时出现 ValueError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64770600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com