安装python3

一、安装依赖环境

输入命令: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

yum install libffi-devel -y

二, 下载并解压文件

yum -y install wget

cd /opt/    wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz

 tar -zxvf Python-3.7.1.tgz

三 创建安装目录 

mkdir -p /usr/local/python3

四 编译

yum install gcc

cd Python-3.7.1

./configure --prefix=/usr/local/python3  

make install

五 建立连接 和添加到PATH

ln -s /usr/local/python3/bin/python3 /usr/bin/python3

ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

 vim /etc/profile

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

export PATH

source ~/.bash_profile

 

 

虚拟环境: 

pip3 install virtualenv

 virtualenv --system-site-packages myenv
source myenv/bin/activate
deactivate
posted @ 2021-03-13 07:16  countryboy666  阅读(58)  评论(0编辑  收藏  举报