python 服务器环境搭建

一、安装python3
0.首先安装相关包

yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
yum install libffi-devel -y

1.下载python3

wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz

2.解压并安装

tar -zxvf Python-3.7.0.tgz
cd Python-3.7.0
./configure
make&&make install

3.配置环境变量

mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python3 /usr/bin/python
mv /usr/bin/pip /usr/bin/pip.bak
ln -s /usr/local/bin/pip3 /usr/bin/pip

4.验证
直接运行python,查看版本号。
5.配置yum
将这两个文件第一行都改成/usr/bin/python2.7

vi /usr/libexec/urlgrabber-ext-down
vi /usr/bin/yum

6.python3 安装完毕

二、virtualenv 虚拟环境安装
1.yum install python-virtualenv
2.virtualenv env -p /usr/local/bin/python3.7
3.进入虚拟环境source py3/bin/activate
4.退出虚拟环境deactivate

ok.

你可能感兴趣的:(python 服务器环境搭建)