美文网首页
Python安装流程

Python安装流程

作者: Chris0Yang | 来源:发表于2021-05-12 17:40 被阅读0次

一、python2 安装 pip

wget下载

wget https://bootstrap.pypa.io/pip/2.7/get-pip.py 
python get-pip.py

# 安装pip版本
python -m pip install --upgrade pip==20.3.0

# 查看pip版本
pip -V

二、python3 安装流程

安装python依赖包

yum -y install zlib-devel bzip2-devel openssl-devel ncures-devel sqlite-devel readline-devel tk-devel uwsgi-plugin-python gcc make 

解压和安装软件包

cd /opt
wget https://www.python.org/ftp/python/3.6.10/Python-3.6.10.tgz
tar -zxf  /opt/Python-3.6.10.tgz -C /usr/local/src      # src目录是存放源码目录解压到src目录

cd /usr/local/src/Python-3.6.10/
./configure --prefix=/usr/local/python3

make && make install

添加环境变量

ln -s /usr/local/python3/bin/pip3.6 /usr/bin/pip3   # 添加pip环境软连接

并将/usr/local/python3/bin加入PATH

vim ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
export PATH
或者
echo "export PATH=$PATH:/usr/local/python3/bin" >>/etc/profile

修改完记得执行行下面的命令,让上一步的修改生效:

source ~/.bash_profile

检查Python3及pip3是否正常可用:

# python3 -V
Python 3.6.1
# pip3 -V
pip 9.0.1 from /usr/local/python3/lib/python3.6/site-packages (python 3.6)

卸载Python3

1、卸载python3
rpm -qa|grep python3|xargs rpm -ev --allmatches --nodeps

2、删除所有残余文件
whereis python3 |xargs rm -frv 

3、查看现有安装的python
whereis python         

相关文章

网友评论

      本文标题:Python安装流程

      本文链接:https://www.haomeiwen.com/subject/eqbudltx.html