centos7安装python3.8

3-30 770 views

1.安装python 依赖

sudo yum -y install epel-release
sudo yum -y update

安装完后可以 reboot 重其服务器,非必须。

2.安装gcc编译环境等等

sudo yum -y groupinstall "Development Tools"
sudo yum -y install openssl-devel bzip2-devel libffi-devel xz-devel

查看gcc版本

$ gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

3.下载编辑安装python3.8

sudo yum -y install wget
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tgz

解压

tar xvf Python-3.8.12.tgz

编译安装

cd Python-3.8*/
$ ./configure --enable-optimizations
$ sudo make altinstall

安装成功显示:

.....
copying build/scripts-3.8/pydoc3.8 -> /usr/local/bin
copying build/scripts-3.8/idle3.8 -> /usr/local/bin
copying build/scripts-3.8/2to3-3.8 -> /usr/local/bin
changing mode of /usr/local/bin/pydoc3.8 to 755
changing mode of /usr/local/bin/idle3.8 to 755
changing mode of /usr/local/bin/2to3-3.8 to 755
rm /usr/local/lib/python3.8/lib-dynload/_sysconfigdata__linux_x86_64-linux-gnu.py
rm -r /usr/local/lib/python3.8/lib-dynload/__pycache__
/usr/bin/install -c -m 644 ./Misc/python.man \
    /usr/local/share/man/man1/python3.8.1
if test "xupgrade" != "xno"  ; then \
    case upgrade in \
        upgrade) ensurepip="--altinstall --upgrade" ;; \
        install|*) ensurepip="--altinstall" ;; \
    esac; \
     ./python -E -m ensurepip \
        $ensurepip --root=/ ; \
fi
Looking in links: /tmp/tmpy9yqf1bp
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-19.2.3 setuptools-41.2.0

4.查看版本

$ python3.8 --version
Python 3.8.12
$ pip3.8 --version
pip 19.2.3 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)

参考:
https://computingforgeeks.com/how-to-install-python-3-on-centos/

python清空文件夹下log文件

#!/usr/bin/python import os import sys files_list = [] def print_files(path): lsdir = os.listdir(path) dirs = [i for i in lsdir if os.path...

阅读全文

python paramiko(SFTP) 相关文档

python paramiko SFTP文档地址: http://docs.paramiko.org/en/2.4/api/sftp.html import paramiko host = "THEHOST.com" #...

阅读全文

python 执行cmd命令并获取pid

process = subprocess.Popen('cmd命令') pid = process.pid print(pid)

阅读全文

1 条评论

欢迎留言