当前位置:首页 >> 脚本专栏

python3.7中安装paddleocr及paddlepaddle包的多种方法

升级pip

pip版本必须升级到20.0.4版本才能应用;

方法一、在pycharm中对pip进行升级;

python3.7中安装paddleocr及paddlepaddle包的多种方法

方法二、通过命令进行升级

python3.7 -m pip install --upgrade pip

下载paddleOCR

下载链接:https://github.com/PaddlePaddle/PaddleOCR

打开paddleOCR文件夹中requirements.txt文件,更改文件中opencv-python为opencv-python == 4.2.0.32,因为支持paddlepaddle的opencv版本需小于等于4.2.0.32;

通过requirements.txt文件安装其依赖项:

 pip3.7 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

安装paddleocr和paddlepaddle

pip3.7 install -i https://pypi.tuna.tsinghua.edu.cn/simple paddleocr
 pip3.7 install -i https://pypi.tuna.tsinghua.edu.cn/simple paddlepaddle

测试是否安装成功

from paddleocr import PaddleOCR, draw_ocr
 
def init():
  ocr = PaddleOCR(use_angle_cls=True, lang="ch") # need to run only once to download and load model into memory
  img_path = './data/3.jpg'
  result = ocr.ocr(img_path, cls=True)
  for line in result:
    print(line)
 
 
if __name__ == "__main__":
  init()

若代码正常运行则两个库安装成功。之后就开启你的开发之旅吧!