2021-09-06 Python 安装

yum 安装

yum list | grep python3 | more
yum install python36
pip3 install --upgrade pip

源码安装

  • 安装
yum update
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make
# 选个自己的目录
cd /usr/local/
# 选择自己需要的版本:https://www.python.org/ftp/python/
wget https://www.python.org/ftp/3.7.9/Python-3.7.9.tgz
tar -zxvf Python-3.7.9.tgz
cd Python-3.7.0
./configure --prefix=/usr/local/python3
make && make install
  • 配置环境
# 第一种方式: 加PATH
vim /etc/profile
export PATH=$PATH:/usr/local/python3/bin
source /etc/profile
# 第二种方式:或者软link
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
# 升级 pip和setuptools
pip3 install --upgrade setuptools
pip3 install --upgrade pip
  • 安装virtualenv
pip3 install virtualenv
ln -s /usr/local/python3/bin/virtualenv /usr/bin/virtualenv
virtualenv -p  /usr/local/python3/bin/python3  my_env
source my_project_env/bin/activate
deactivate

参考1
参考2

你可能感兴趣的:(2021-09-06 Python 安装)