题记:第一次学博客,不知道怎么写,就将就看吧!
新手学习python的历程记录,如有错误,请不小心看到的大佬指正!感谢
一、简易安装python3
1.1安装依赖
yum -y install zlib zlib-devel
yum -y install bzip2 bzip2-devel
yum -y install ncurses ncurses-devel
yum -y install readline readline-devel
yum -y install openssl openssl-devel
yum -y install openssl-static
yum -y install xz lzma xz-devel
yum -y install sqlite sqlite-devel
yum -y install gdbm gdbm-devel
yum -y install tk tk-devel
yum -y install libffi libffi-devel
yum -y install gcc
1.2下载python3包
yum install -y wget && wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
mkdir -p /cjm/python
tar -zxvf Python-3.7.2.tgz -C /opt/
1.3编译安装
cd /opt/Python-3.7.2 && ./configure --prefix=/cjm/python/
make && make install
等待安装完即可
现在使用请驶入如下目录/cjm/python/bin/python3
1.4配置环境
如果向直接输入python,就进入python3的环境,请进行如下操作
rm -rf /usr/bin/python
ln -s /cjm/python/bin/python3 /usr/bin/python
sed -i -e "1s|/usr/bin/python|/usr/bin/python2|" /usr/bin/yum
sed -i -e "1s|/usr/bin/python|/usr/bin/python2|" /usr/libexec/urlgrabber-ext-down
sed -i -e "1s|#!/usr/bin/python -tt|#!/usr/bin/python2 -tt|" /bin/yum-config-manager
输入python就如下图显示: