gpt4 book ai didi

python-3.x - 无法在 Windows 10 中运行 Tensorflow

转载 作者:行者123 更新时间:2023-11-30 08:46:16 24 4
gpt4 key购买 nike

我使用cmd命令在Windows 10上成功安装了tensorflow:

pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.0.0-py3-none-any.whl

但是,当我使用 PyCharm 运行简单的代码时,例如:

 import tensorflow as tf
node1 = tf.constant(3.0, dtype=tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly
print(node1, node2)

我在控制台上收到以下错误:

  Traceback (most recent call last):
File "C:\Users\Name\Desktop\Desktop\lib\site-
packages\tensorflow\python\pywrap_tensorflow.py", line 18, in
swig_import_helperfp, pathname, description =
imp.find_module('_pywrap_tensorflow', [dirname(__file__)])
File "C:\Users\Name\Desktop\Desktop\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Name\Desktop\Desktop\lib\site-
packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Name\Desktop\Desktop\lib\site-
packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\Name\Desktop\Desktop\lib\site-
packages\tensorflow\python\pywrap_tensorflow.py", line 20, in
swig_import_helper
import _pywrap_tensorflow
ModuleNotFoundError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Name/Desktop/Desktop/ML/tfbasics.py", line 1, in <module>
import tensorflow as tf
File "C:\Users\Name\Desktop\Desktop\lib\site-
packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\Name\Desktop\Desktop\lib\site-
packages\tensorflow\python\__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Name\Desktop\Desktop\lib\site-
packages\tensorflow\python\pywrap_tensorflow.py", line 18, in
swig_import_helper
fp, pathname, description = imp.find_module('_pywrap_tensorflow',
[dirname(__file__)])
File "C:\Users\Name\Desktop\Desktop\lib\imp.py", line 296, in find_module
raise ImportError(_ERR_MSG.format(name), name=name)
ImportError: No module named '_pywrap_tensorflow'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\Name\Desktop\Desktop\lib\site-
packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Name\Desktop\Desktop\lib\site-
packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\Name\Desktop\Desktop\lib\site-
packages\tensorflow\python\pywrap_tensorflow.py", line 20, in
swig_import_helper
import _pywrap_tensorflow
ModuleNotFoundError: No module named '_pywrap_tensorflow'

我研究了网络来修复这个错误,但发现相互矛盾的结果没有帮助。任何人都可以指出为什么会出现此错误?

最佳答案

我不知道当你想在 Windows 上运行它时为什么使用 Mac

pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.0.0-py3-none-any.whl

来自手册

Issue the appropriate command to install TensorFlow inside your conda environment. To install the CPU-only version of TensorFlow, enter the following command:

(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.3.0-cp35-cp35m-win_amd64.whl To install the GPU version of TensorFlow, enter the following command (on a single line):

(tensorflow)C:> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.3.0-cp35-cp35m-win_amd64.whl

也请不要忘记

TensorFlow only supports version 3.5.x of Python on Windows. Note that Python 3.5.x comes with the pip3 package manager, which is the program you'll use to install TensorFlow.

关于python-3.x - 无法在 Windows 10 中运行 Tensorflow,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45838282/

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