通过 pip 安装 TensorFlow

2024年11月14日 | 阅读时长:3 分钟

在本教程中,我们将描述如何在 Windows 10 中安装 TensorFlow。

我们可以通过两种方式在系统中下载 TensorFlow

  1. 通过 pip (Python 包库)
  2. 通过 Anaconda Navigator (conda)

1. 通过 pip

因此,首先我们必须通过 pip 在我们的系统中安装和设置 anaconda。

以下是 TensorFlow 在我们的计算机上工作的要求。

  • TensorFlow 仅支持 Windows 上的 64 位 Python 3.5.x 或 Python 3.6.x
  • 当我们下载 Python 3.5.x 版本时,它带有 pip3 包管理器。(这是我们用户在 Windows 上安装 TensorFlow 所需的程序)。

步骤 1: 从以下链接下载 Python:https://pythonlang.cn/downloads/release/python-352/

Installation of TensorFlow Through pip
Installation of TensorFlow Through pip

之后,

步骤 3: 我们将被带到另一个页面,我们需要选择 x86-64amd64 安装程序来安装 Python。

我们在这里使用 Windows x86-64 可执行安装程序

Installation of TensorFlow Through pip
Installation of TensorFlow Through pip

现在,Python 正在成功安装。

Installation of TensorFlow Through pip

步骤 4: 对于本教程,我将选择添加 Python 3.5 到 PATH

Installation of TensorFlow Through pip

步骤 5: 现在,我们将能够看到消息“安装成功”。确认它已成功安装的一种方法是打开命令提示符并检查版本。

什么是 pip?

pip 被称为包管理系统,用于安装和管理用 Python 或任何其他语言编写的软件包。 pip 用于下载、搜索、安装、卸载和管理第三方 Python 包。(pip3 是最新版本,它带有我们刚刚下载的新的 Python 3.5.x 版本)

安装我们的 TensorFlow

一旦我们下载了最新版本的 Python,我们现在可以通过安装我们的 TensorFlow 来完成最后的润色。

步骤 1: 要安装 TensorFlow,请启动终端。 确保我们以管理员身份运行 cmd。

如果我们不知道如何以管理员身份运行我们的 cmd

这是我们如何在我们的 cmd 中以管理员身份运行。

打开“开始”菜单,搜索 cmd,然后右键单击它并选择“以管理员身份运行”。

Installation of TensorFlow Through pip

步骤 2: 完成此操作后,我们必须在命令提示符中写入命令,以完成在 Windows 中安装 Tensorflow。

输入此命令


Installation of TensorFlow Through pip
Installation of TensorFlow Through pip
Installation of TensorFlow Through pip

现在,TensorFlow 已成功安装在我们的系统中。

测试我们的 TensorFlow

在这里,我们尝试证明我们的新 TensorFlow 是否运行顺利,没有任何问题。

以下是一个可以用来测试的例子。

Installation of TensorFlow Through pip

TensorFlow 现在正在成功运行。

否则,如果我们运行该程序时遇到任何问题,那么我们必须安装 Microsoft Visual C++ 2015。 并在我们的系统中设置,然后 TensorFlow 将在系统中运行。

我们可以从以下链接下载 Microsoft Visual C++ 2015:https://www.microsoft.com/en-us/download/confirmation.aspx?id=53587

Installation of TensorFlow Through pip

我们可以从这里下载。

Installation of TensorFlow Through pip

在页面上选择 vc_redist.x64.exe,然后单击“下一步”,之后它将被下载。

Installation of TensorFlow Through pip
Installation of TensorFlow Through pip

最后,它将成功安装在我们的系统中。

我们将在下一个教程中阅读 conda install TensorFlow