笔记-python-centos环境下安装配置

时间:2023-03-08 16:54:19

笔记-python-centos环境下安装配置

1.      准备工作

  1. 环境准备

centos6.5 mini,已有python 2.6.6

  1. 下载源码包

Python官网下载Gzipped source tarball(版本3.6.5)

tar –xvf ……

  1. 安装环境

mkdir /usr/local/python3.6.5

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

  1. 开始安装

./configure

报错no acceptable C compiler found

安装gcc编译器 yum -y install gcc

  1. 编译安装

./configure –prefix=/usr/local/python3.6.5

make && make install

  1. 添加环境变量

vi ~/.bash_profile

修改下面一行

PATH=$PATH:$HOME/bin:/usr/local/python3/bin

使环境变量生效

source ~/.bash_profile

建立软链接

ln -s /usr/local/python3.6.5/bin/python3.6 /usr/bin/python3

  1. 验证

python3 –V

pip3 -V