一、安装PYTHON 编译依赖

1.1 首先安装gcc编译器gcc有些系统版本已经默认安装通过 gccversion 查看,没安装的先安装gcc
yum -y install gcc glibc make
1.2 安装其它依赖包,(注:不要缺少,否则有可能安装python出错,python3.7.0以下的版本可不装 libffidevel
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
1.3 下载python源码包,此处我选择安装 python:3.7.4
wget https://www.python.org/ftp/python/3.7.4/Python-3.7.4.tgz
1.4 解压源码
tar zxvf Python-3.7.4.tgz 
1.5 编译python
# 新建一个目录用来存放安装python3 程序
mkdir /opt/app/python3.7.4

# 切换解压包之后的Python3.7.4目录
cd Python-3.7.4

# ./configure 用来生成编译参数,--prefix 用来指定安装目录,此处填写刚刚创建绝对路径/opt/app/python3.7.4
./configure --prefix=/opt/app/python3.7.4

# make生成二进制安装文件make install 用来进行执行安装。  
make && make install

看到如下文时,证明安装成功。

Looking in links: /tmp/tmpf2__yj7o
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.0.3 setuptools-40.8.0
1.6 创建连接

注:软连接用来生成打开快捷方式,同时用来区分python2 和 python3。

ln -s /opt/app/python3.7.4/bin/python3.7 /usr/bin/python3.7
ln -s /opt/app/python3.7.4/bin/pip3.7 /usr/bin/pip3.7
1.7 测试是否可用
[root@iZj6cdf4xm0h3m0do5ojkjZ ~]# python3.7 -V
Python 3.7.4
[root@iZj6cdf4xm0h3m0do5ojkjZ ~]# python3.7 
Python 3.7.4 (default, Jan 20 2020, 20:02:14) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello World")
Hello World
>>> exit()

二、 安装模块

pip3.7 install requests
更新
 pip3.7 install --upgrade pip
pip3.7 install pymysql

pip3.7 install pillow

安装图形识别模块
 pip3.7 install tesserocr

注:此时会有报错

    gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/opt/app/python3.7.4/include/python3.7m -c tesserocr.cpp -o build/temp.linux-x86_64-3.7/tesserocr.o
    gcc: error trying to exec 'cc1plus': execvp: No such file or directory
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /opt/app/python3.7.4/bin/python3.7 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-4e_e9xf2/tesserocr/setup.py'"'"'; __file__='"'"'/tmp/pip-install-4e_e9xf2/tesserocr/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-k1lj6ss7/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

解决方法

yum -y install tesseract-devel 
yum -y install gcc-c++

再次安装,无问题

 pip3.7 install tesserocr
Looking in indexes: http://mirrors.cloud.aliyuncs.com/pypi/simple/
Collecting tesserocr
  Downloading http://mirrors.cloud.aliyuncs.com/pypi/packages/e3/77/fb26b321c3b9ce4a47af12b19e85ddbf4d0629adb6552d85276e824e6e51/tesserocr-2.5.0.tar.gz (54kB)
     |████████████████████████████████| 61kB 44.4MB/s 
Installing collected packages: tesserocr
    Running setup.py install for tesserocr ... done
Successfully installed tesserocr-2.5.0

pip3.7 install tesseract-ocr

原文地址:https://blog.csdn.net/cljdsc/article/details/134586931

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_17259.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注