Centos 8.2 安装配置Python3.6

Centos 8.2 安装配置Python3.6

一、测试环境:

系统版别:Centos8.2

Python版本:3.6

Oracle客户端:12

远程工具:Xshell

二、Centos升级:

Centos修改镜像源

#请配置好网络环境
#最好将镜像源设置为国内
dnf -y update
#xshell文件传输包,安装后可以直接拖拽文件(不会覆盖现有文件)
yum -y install lrzsz 

三、Python3.6安装:

查看Python3是否安装

[root@DA-Python /]# whereis python
python: /usr/lib/python3.6 /usr/lib64/python3.6 /usr/local/lib/python3.6 /usr/include/python3.6m /usr/share/man/man1/python.1.gz
[root@DA-Python /]# python3.6
-bash: python3.6: command not found

安装Python3.6:

[root@DA-Python /]# dnf -y install python36
[root@DA-Python /]# whereis python
python: /usr/bin/python3.6 /usr/bin/python3.6m /usr/lib/python3.6 /usr/lib64/python3.6 /usr/local/lib/python3.6 /usr/include/python3.6m /usr/share/man/man1/python.1.gz
#python3.6安装后会自动创建/usr/bin/python3链接,可以直接使用python3命令
#如果想使用python创建python连接即可
#ln -s /usr/local/python3.6/bin/python3.6 /usr/bin/python
[root@DA-Python /]# python3
Python 3.6.8 (default, Apr 16 2020, 01:36:27) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

四、pip3安装设置:

centos8.2自带pip3

[root@DA-Python /]# whereis pip3
pip3: /usr/bin/pip3 /usr/bin/pip3.6 /usr/share/man/man1/pip3.1.gz

修改pip镜像源

[root@DA-Python ~]# mkdir /Data/pip
[root@DA-Python ~]# vi /Data/pip/pip.conf
#添加如下内容
[global]
timeout = 6000
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

五、oracle客户端安装:

Oracle12客户端安装

上传Oracle客户端rmp文件:

安装Oracle客户端:

[root@DA-Python Data]# cd /Data/SoftTools/
[root@DA-Python SoftTools]# rpm -ivh oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm

配置环境变量:

[root@DA-Python SoftTools]# vi /etc/profile
#添加如下内容
export ORACLE_HOME=/usr/lib/oracle/12.2/client64/lib
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME

#保存配置文件
source /etc/profile

六、安装python包:

[root@DA-Python ~]# pip3 install cx_Oracle
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting cx_Oracle
  Downloading https://mirrors.aliyun.com/pypi/packages/9f/ce/9117cc84d05800b7962f1842bf5fb20455ee08264cda052a3c79d476cf01/cx_Oracle-8.0.1-cp36-cp36m-manylinux1_x86_64.whl (756kB)
    100% |████████████████████████████████| 757kB 21.9MB/s 
Installing collected packages: cx-Oracle
Successfully installed cx-Oracle-8.0.1
#类似可以安装
pymysql,pymongo,requests,pandas,numpy ...

七、编写python脚本:

#!/usr/bin/python3
import booksaleanalysisupdatestock
'''
    系统版本:Centos8.2
    Python版本:3.6
    Oracle客户端:12
    机器配置:2X,16G,200G
    Log路径:/Data/Logs
'''
flag,msgword=booksaleanalysisupdatestock.bookstockTransfer()
print(msgword)

八、编写sh脚本:

#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
source /root/.bash_profile
cd /Data/DataAnalysis/
python3 cronControl.py > /Data/Logs/dataAnalysis.log

赋值执行权限

chmod +x /Data/DataAnalysis/cronControl.sh

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值