使用 Pip 安装 Animius

Animius can be installed as a Pypi package. If you do not wish to install Animius manually and GPU support on Windows is not a concern (read more about GPU support here), installing via Docker can be a easier and cleaner approach.

Animius 可以通过 Pypi 包的形式安装. 如果你不想手动安装 Animius, 并且不希望在 Windows 上使用 GPU (阅读更多关于 GPU 支持的内容), 使用 Docker 安装 Animius 更加简单且有效.

系统要求

1. 安装 Python

首先, 查看你的 Python 环境是否正确配置:

python3 --version
pip3 --version
virtualenv --version

如果这些包正确安装, 请移至下一步.

若没有正确安装, 请安装 Python 3.6.8 (Animius 暂时不支持 Python 3.7), Pip 包管理器, 和 Virtualenv 虚拟环境:

# 从 https://www.python.org/downloads/release/python-368/ 下载 Python 3.6.8 64-bit 

pip3 install -U pip virtualenv
# 从源码编译 Python 3.6.8.
wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
tar xvf Python-3.6.8.tgz
cd Python-3.6.8
./configure --enable-optimizations
make -j8
sudo make altinstall

# 安装 Pip
sudo apt update
sudo apt install python3-pip
sudo pip3 install -U virtualenv  # system-wide install
# 从 https://www.python.org/downloads/release/python-368/ 下载 Python 3.6.8 64-bit 

sudo pip3 install -U virtualenv  # 为操作系统安装

2. 创建虚拟环境 (推荐)

Python 虚拟环境可以将安装过程和系统环境隔离.

# Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:
virtualenv --system-site-packages -p python3 ./venv

# Activate the virtual environment:
.\venv\Scripts\activate

# Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip:
pip install --upgrade pip
pip list  # show packages installed within the virtual environment

# And to exit virtualenv later:
deactivate  # don't exit until you're done using Animius
# Create a new virtual environment by choosing a Python interpreter and making a ./venv directory to hold it:
virtualenv --system-site-packages -p python3 ./venv

# Activate the virtual environment using a shell-specific command:
source ./venv/bin/activate  # sh, bash, ksh, or zsh

# When virtualenv is active, your shell prompt is prefixed with (venv).
# Install packages within a virtual environment without affecting the host system setup. Start by upgrading pip:
pip install --upgrade pip
pip list  # show packages installed within the virtual environment

# And to exit virtualenv later:
deactivate  # don't exit until you're done using Animius

3. 安装 TensorFlow

Animius 要求用户手动安装 TensorFlow. (除非你使用 Docker) 用户可以自行选择 CPU 或 GPU 版本的 TensorFlow. 请参考 “GPU 支持” 了解更多关于 CPU 和 GPU 的资料.

Animius 不支持 TensorFlow 2.0.

pip install --upgrade tensorflow==1.12.0.   # CPU
pip install --upgrade tensorflow-gpu==1.12.0.   # GPU

对于中国大陆的用户, 你可以使用清华大学提供的 Pypi 镜像来加速下载过程:

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow==1.12.0.   # CPU-only
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade tensorflow-gpu==1.12.0.   # GPU

4. 安装 Animius

使用 Pip 安装 Animius

pip install --upgrade animius

  Animius 安装成功. 请查阅使用教程.