登录Python官网去下载对应的版本:Python下载地址
在data目录下创建python文件夹
mkdir python上传下载的安装包
Python-3.8.18.tgz解压
tar -xf Python-3.8.18.tgz进入解压后的目录
cd Python-3.8.18/编译安装
./configure --prefix=/data/python38
make && make install配置环境
vim .bash_profile
#配置python
export PYTHON_HOME=/data/python38
export PATH=$PYTHON_HOME/bin:$PATH加载配置文件
source .bash_profile进入python窗口验证
python3.8
Python 3.8.18 (default, Dec 26 2024, 14:11:24)
[GCC 8.5.0 20210514 (Anolis 8.5.0-10.0.1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>exit() 退出窗口查看安装的模块
pip3.8 list
Package Version
---------- -------
pip 23.0.1
setuptools 56.0.0安装模块
pip3.8 install *
Pip3.8 install pandas安装模块列表
pip3.8 install -r requirements.txt列表中是需要下载的模块
cat requirements.txt
?tbcrypt==4.2.1
certifi==2024.12.14
cffi==1.17.1
charset-normalizer==3.4.0
cryptography==44.0.0
et_xmlfile==2.0.0
idna==3.10
numpy==1.24.4
openpyxl==3.1.5
packaging==24.1
pandas==2.0.3
paramiko==3.5.0
pycparser==2.22
pycryptodome==3.21.0
PyNaCl==1.5.0
python-dateutil==2.9.0.post0
pytz==2024.2
requests==2.32.3
six==1.17.0
suds==1.2.0
tensorflow-addons==0.21.0
typeguard==2.13.3
tzdata==2024.2
urllib3==1.26.20查看模块版本
pip3.8 show *
pip3.8 show numpy
Name: numpy
Version: 1.24.4
Summary: Fundamental package for array computing in Python
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email:
License: BSD-3-Clause
Location: /home/weblogic/python/lib/python3.8/site-packages
Requires:
Required-by: pandas运行脚本pythonPython3.8 ***.py即可例如:打印Hello Word
vim ceshi.py print('Hello Word')执行python脚本
python3.8 ceshi.py
Hello Word如果要定时执行python脚本
可通过linux crontab来执行编写一个shell 来执 python脚本
vim test.sh
nohup /data/python38/bin/python3.8 -u /data/ceshi.py >> /data/ceshi.log 2>&1 &注释: /data/ceshi.py(python脚本路径)
/data/ceshi.log(输出的日志路径)Shell定时任务
crontab -e
00 12 * * * /data/ceshi.sh >>/data/ceshi.log /dev/null 2>&1