Pybrain 简明教程

PyBrain - Environment Setup

在本章中,我们将进行 PyBrain 的安装。要开始使用 PyBrain,我们需要首先安装 Python。因此,我们将开展以下工作 −

In this chapter, we will work on the installation of PyBrain. To start working with PyBrain, we need to install Python first. So we are going to work on following −

  1. Install Python

  2. Install PyBrain

Installing Python

要安装 Python,请访问 Python 官方网站: www.python.org/downloads ,如下所示,然后单击适用于 Windows、Linux/Unix 和 macOS 的最新版本。根据您可用的 64 位或 32 位操作系统下载 Python。

To install Python, go to the Python official site: www.python.org/downloads as shown below and click on the latest version available for windows, Linux/Unix and macOS. Download Python as per your 64- or 32-bit OS available with you.

installing python

下载后,单击 .exe 文件并按照步骤在您的系统上安装 python。

Once you have downloaded, click on the .exe file and follow the steps to install python on your system.

setup progress

python 软件包管理器,即 pip,也将默认情况下通过上述安装进行安装。要使其在您的系统上全局运行,请将 python 的位置直接添加到 PATH 变量中,在安装开始时显示了相同的变量,以便记住选中复选框,该复选框表示添加到 PATH。如果您忘记选中该复选框,请按照下面给定的步骤将其添加到 PATH。

The python package manager, i.e., pip will also get installed by default with the above installation. To make it work globally on your system, directly add the location of python to the PATH variable, the same is shown at the start of the installation to remember to check the checkbox which says ADD to PATH. In case you forget to check it please follow the below given steps to add to PATH.

Add to PATH

要添加到 PATH,请按照以下步骤操作 −

To add to PATH, follow the below steps −

  1. Right-click on your Computer icon and click on properties → Advanced System Settings.

  2. It will display the screen as shown below

system properties
  1. Click on Environment Variables as shown above. It will display the screen as shown below

environment variables

选择“路径”并单击“编辑”按钮,在末尾添加 Python 的位置路径。现在,让我们检查 Python 版本。

Select Path and click on Edit button, add the location path of your python at the end. Now let us check the python version.

Checking for Python version

以下代码帮助我们检查 Python 版本:

The below code helps us in checking the version of Python −

E:\pybrain>python --version
Python 3.7.3

Installing PyBrain

现在我们已经安装了 Python,我们准备安装 Pybrain。按如下所示克隆 Pybrain 仓库:

Now that we have installed Python, we are going to install Pybrain. Clone the pybrain repository as shown below −

git clone git://github.com/pybrain/pybrain.git
C:\pybrain>git clone git://github.com/pybrain/pybrain.git
Cloning into 'pybrain'...
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 12177 (delta 0), reused 0 (delta 0), pack-reused 12175
Receiving objects: 100% (12177/12177), 13.29 MiB | 510.00 KiB/s, done.
Resolving deltas: 100% (8506/8506), done.

现在,执行 cd pybrain 并运行以下命令:

Now perform cd pybrain and run following command −

python setup.py install

此命令会在你的系统中安装 Pybrain。

This command will install pybrain on your system.

完成以后,为了检查 Pybrain 是否已安装,请打开命令行提示符并启动 Python 解释器,如下所示:

Once done, to check if pybrain is installed or not, open command line prompt and start the python interpreter as shown below −

C:\pybrain\pybrain>python
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

我们可以使用如下代码添加 import pybrain:

We can add import pybrain using the below code −

>>> import pybrain
>>>

如果 import pybrain 可以正常运行,则表明 Pybrain 已成功安装。你现在可以编写代码以开始使用 Pybrain。

If the import pybrain works without any errors, it means pybrain in installed successfully. You can now write your code to start working with pybrain.