发布时间:2019-09-25 08:24:51编辑:auto阅读(1704)
linux下python的安装
安装步骤如下
1 准备编译环境
yum groupinstall 'Development Tools'
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel sqlit
2 下载 Python3.5代码包
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
3 编译
tar Jxvf Python-3.5.2.tar.xz
cd Python-3.5.2
./configure --prefix=/usr/local/python3
make && make install
4 设置环境变量
echo 'export PATH=$PATH:/usr/local/python3/bin' >> ~/.bashrc
5 设置目录(这样做的目的是在系统任意目录敲入python3调用的是python3.5的命令)
mv /usr/bin/python /usr/local/python.bak
rm -rf /usr/local/python2
ln -sv /usr/local/python2.6 /usr/bin/python2
ln -sv /usr/local/python3/bin/python3.5 /usr/bin/python
6 修改yum脚本,使其指向旧版本的python,已避免yum无法运行
sed -i 's$#!/usr/bin/python$#!/usr/bin/python2.6$g' /usr/bin/yum
7 测试
输入python 显示如下
上一篇: Scrapy:python3下的第一次运
下一篇: windows下安装python2与py
47760
46269
37152
34655
29246
25906
24778
19878
19441
17933
5730°
6335°
5853°
5903°
7004°
5841°
5860°
6372°
6331°
7695°