#安装python2.7之前,准备工作:
yum install python-devel gcc patch readline* -y
#解压并安装:
tar xf Python-2.7.10.tar.xz cd Python-2.7.10 sed -i ‘s/#readline/readline/g‘ Modules/Setup.dist ./configure --prefix=/usr/local/python make && make install
#更改系统python调用
mv /usr/bin/python /usr/bin/python_old ln -s /usr/local/python/bin/python /usr/bin/python
#更改yum程序,调用老的的python
sed -i ‘s/python/python_old/g‘ /usr/bin/yum
#shell python tab自动补全
cat > ~/.pythonconf << EOF import readline, rlcompleter readline.parse_and_bind("tab: complete") EOF
#添加环境变量
echo "export PYTHONSTARTUP=~/.pythonconf" >> ~/.bashrc source ~/.bashrc
时间: 2024-11-08 19:15:27