Help Center> Optical Character Recognition> SDK Reference> SDK Environment Setup> Preparing a Python Development Environment

Preparing a Python Development Environment

Scenario

OCR Python SDK supports Windows, Linux, and Mac operating systems. This section uses Windows as an example to describe how to configure the environment. Table 1 describes the required operating environment.

Table 1 Environment preparation

Item

Description

OS

Windows OS. Windows 7 or later is recommended.

Installing Python

Python 2.7 or later is recommended.

Installing Python library dependency

OCR Python SDK depends on the third-party requests 2.18.2 library package.

Procedure

The following describes how to install and configure Python 2.7 in the Windows 7 environment. If you have installed Python 2.7 or later and requests 2.18.2, skip this section.

  1. Download your desired Python installation package from https://www.python.org/downloads/release/python-2711/
  2. After the Python installation package is downloaded, install it as prompted. The default path is C:\Python27.
  3. Right-click Computer, choose Properties > Advanced System Settings > Environment Variables. Add C:\Python27;C:\Python27\Scripts to Path.
  4. Open the command line interface (CLI) and run python –v. If the information shown in Figure 1 is displayed, the configuration is successful.
    Figure 1 Python version information
  5. Run the following command in the new CMD window of PIP to install the requests package:
    1
    pip install -i https://pypi.tuna.tsinghua.edu.cn/simple requests --trusted-host https://pypi.tuna.tsinghua.edu.cn/simple
    
  6. After the installation is complete, run the PIP command to check whether the requests package is correctly installed. See Figure 2.
    Figure 2 Installation confirmation