一、python环境准备
1.安装依赖
[root@localhost Python-3.6.15]# yum install gcc
2.官网下载安装包
wget https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz
3.解压缩安装包
tar -zxf Python-3.6.15.tgz
4.编译安装
cd Python-3.6.15 [root@localhost Python-3.6.15]# ./configure --prefix=/usr/local/python3 checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking for python3.6... no checking for python3... no checking for python... no checking for --enable-universalsdk... no checking for --with-universal-archs... no checking MACHDEP... linux checking for --without-gcc... no checking for --with-icc... no checking for gcc... gcc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for grep that handles long lines and -e... /usr/bin/grep checking for a sed that does not truncate output... /usr/bin/sed checking for --with-cxx-main=<compiler>... no checking for g++... no If you want a release build with all stable optimizations active (PGO, etc), please run ./configure --enable-optimizations [root@localhost Python-3.6.15]#
5完成后执行make
[root@localhost Python-3.6.15]# make [root@localhost Python-3.6.15]# make install
6.创建新版本的链接
[root@localhost Python-3.6.15]# ln -s /usr/local/python3/bin/python3 /usr/bin/python
7.验证版本
[root@localhost ~]# python -V Python 3.6.15
软连接创建成功
8,需进一步配置pip3
[root@localhost ~]# vim /etc/profile
末尾加入
PATH=$PATH:$HOME/bin: PATH=$PATH:$HOME/bin:/usr/local/python3/bin
完成后,这时pip3就可以使用了。
版权声明
本文仅代表作者观点,不代表百度立场。
本文系作者授权百度百家发表,未经许可,不得转载。