python相关环境搭建

由于算法模块需要调用python算法文件,因此本系统部署时需要相应的python环境。

  • python 版本 3.10
  • scikit-learn包
  • redis python包

python 3.10安装

  • 在官网下载python 3.10.1的压缩包:https://www.python.org/ftp/python/3.10.1/Python-3.10.1.tgz

    • 首先安装gcc编译器,gcc有些系统版本已经默认安装,通过 gcc --version 查看,没安装的先安装gcc,yum -y install gcc
    • 安装其它依赖包,(注:不要缺少,否则有可能安装python出错,python3.7以下的版本可不装 libffi-devel )

    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

  • 然后通过XFTP丢到服务器上去,路径:/usr/local/python3

  • cd 到新建的python3文件夹中 进行解压 tar -xvf xxx

  • cd 到解压完的文件中 添加配置:

    • ./configure --prefix=/usr/local/python3(存放python3的文件夹)
  • 编译 make

  • 安装 make install

  • 建立软连接:

    • ln -s /usr/local/python3/bin/python3.10.1 /usr/bin/python3
    • ln -s /usr/local/python3/bin/pip3.10 /usr/bin/pip3
  • 查看python3是否安装成功:

    • python3 --version

scikit-learn 安装

  • pip3 install scikit-learn -i https://pypi.tuna.tsinghua.edu.cn/simple

redis python包支持安装

  • pip3 install redis -i https://pypi.tuna.tsinghua.edu.cn/simple

包安装失败

如果在使用pip3安装scikit-learn或者redis包是发生错误如下:

pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available

此时需要安装openssl,步骤如下:

  • 编译安装 openssl
    • wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz
    • tar -xzvf openssl-1.1.1l.tar.gz
    • cd openssl-1.1.1l
    • ./config shared zlib --prefix=/usr/local/openssl
    • make && make install
  • 创建软连接
    • ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
    • ln -s /usr/local/openssl/include/openssl/ /usr/include/openssl
    • echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
    • ldconfig
  • 查看安装是否成功
    • openssl version
  • 重新编译python 3.10
    • cd /usr/local/python3
    • ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl/
    • make && make install
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Honey Ro

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值