Environment Preparation¶
Windows and Mac users are recommended to use Anaconda to build a Python environment, and Linux users are recommended to use docker to build a Python environment.
Recommended working environment:
- PaddlePaddle >= 2.1.2
- Python 3.7
- CUDA 10.1 / CUDA 10.2
- cuDNN 7.6
If you already have a Python environment installed, you can skip to PaddleOCR Quick Start.
1. Python Environment Setup¶
1.1 Windows¶
1.1.1 Install Anaconda¶
-
Note: To use PaddlePaddle you need to install python environment first, here we choose python integrated environment Anaconda toolkit
-
Anaconda is a common python package manager
-
After installing Anaconda, you can install the python environment, as well as numpy and other required toolkit environment.
-
Anaconda download.
-
Address: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D
-
Most Win10 computers are 64-bit operating systems, choose x86_64 version; if the computer is a 32-bit operating system, choose x86.exe
-
After the download is complete, double-click the installer to enter the graphical interface
-
The default installation location is C drive, it is recommended to change the installation location to D drive.
-
Check Conda to add environment variables and ignore the warning that
1.1.2 Opening the terminal and creating the Conda environment¶
- Open Anaconda Prompt terminal: bottom left Windows Start Menu -> Anaconda3 -> Anaconda Prompt start console
- Create a new Conda environment
This command will create an executable environment named paddle_env with python version 3.8, which will take a while depending on the network status
The command line will then output a prompt, type y and enter to continue the installation
- To activate the Conda environment you just created, enter the following command at the command line.
The above anaconda environment and python environment are installed
1.2 Mac¶
1.2.1 Installing Anaconda¶
-
Note: To use PaddlePaddle you need to install the python environment first, here we choose the python integrated environment Anaconda toolkit
-
Anaconda is a common python package manager
-
After installing Anaconda, you can install the python environment, as well as numpy and other required toolkit environment
-
Anaconda download:.
-
Address: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D
-
Select
Anaconda3-2021.05-MacOSX-x86_64.pkg
at the bottom to download -
After downloading, double click on the .pkg file to enter the graphical interface
-
Just follow the default settings, it will take a while to install
-
It is recommended to install a code editor such as VSCode or PyCharm
1.2.2 Open a terminal and create a Conda environment¶
-
Open the terminal
-
Press command and spacebar at the same time, type "terminal" in the focus search, double click to enter terminal
-
Add Conda to the environment variables
-
Environment variables are added so that the system can recognize the Conda command
-
Open
~/.bash_profile
in the terminal by typing the following command. -
Add Conda as an environment variable in
~/.bash_profile
.- When you are done, press
esc
to exit edit mode, then type:wq!
and enter to save and exit
- When you are done, press
-
Verify that the Conda command is recognized.
- Enter
source ~/.bash_profile
in the terminal to update the environment variables - Enter
conda info --envs
in the terminal again, if it shows that there is a base environment, then Conda has been added to the environment variables
- Enter
-
Create a new Conda environment
-
This command will create an executable environment named paddle_env with python version 3.8, which will take a while depending on the network status
-
The command line will then output a prompt, type y and enter to continue the installation
-
To activate the Conda environment you just created, enter the following command at the command line.
The above anaconda environment and python environment are installed
1.3 Linux¶
Linux users can choose to run either Anaconda or Docker. If you are familiar with Docker and need to train the PaddleOCR model, it is recommended to use the Docker environment, where the development process of PaddleOCR is run. If you are not familiar with Docker, you can also use Anaconda to run the project.
1.3.1 Anaconda environment configuration¶
-
Note: To use PaddlePaddle you need to install the python environment first, here we choose the python integrated environment Anaconda toolkit
-
Anaconda is a common python package manager
-
After installing Anaconda, you can install the python environment, as well as numpy and other required toolkit environment
-
Download Anaconda.
-
Download at: https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=M&O=D
-
Select the appropriate version for your operating system
- Type
uname -m
in the terminal to check the command set used by your system
- Type
-
Download method 1: Download locally, then transfer the installation package to the Linux server
-
Download method 2: Directly use Linux command line to download
-
To install Anaconda.
-
Type
sh Anaconda3-2021.05-Linux-x86_64.sh
at the command line- If you downloaded a different version, replace the file name of the command with the name of the file you downloaded
-
Just follow the installation instructions
- You can exit by typing q when viewing the license
-
Add conda to the environment variables
-
If you have already added conda to the environment variable path during the installation, you can skip this step
-
Open
~/.bashrc
in a terminal. -
Add conda as an environment variable in
~/.bashrc
.- When you are done, press
esc
to exit edit mode, then type:wq!
and enter to save and exit
- When you are done, press
-
Verify that the Conda command is recognized.
- Enter
source ~/.bash_profile
in the terminal to update the environment variables - Enter
conda info --envs
in the terminal again, if it shows that there is a base environment, then Conda has been added to the environment variables
- Enter
-
Create a new Conda environment
-
This command will create an executable environment named paddle_env with python version 3.8, which will take a while depending on the network status
-
The command line will then output a prompt, type y and enter to continue the installation
-
To activate the Conda environment you just created, enter the following command at the command line.
The above anaconda environment and python environment are installed
1.3.2 Docker environment preparation¶
The first time you use this docker image, it will be downloaded automatically. Please be patient.
You can also visit DockerHub to get the image that fits your machine.