python升级

2023-09-20 19:36:34 浏览数 (2)

安装系统后python版本低 需要更新更高版本

代码语言:javascript复制
wget https://www.python.org/ftp/python/2.7.9/Python-2.7.9.tgz
代码语言:javascript复制
tar zxvf Python-2.7.9.tgz
./configure 
make install
make
 
mv /usr/bin/python /usr/bin/python_old
ln -s /usr/local/bin/python2.7 usr/bin/

修改yum配置文件以保证yum可用

代码语言:javascript复制
vim /usr/bin/yum
#!/usr/bin/python   #修改此处为/usr/bin/python_old

PYPY:http://pkgs.org/search/?keyword=pypy

代码语言:javascript复制
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/pypy-libs-2.0.2-1.el6.x86_64.rpm
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/pypy-2.0.2-1.el6.x86_64.rpm
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/pypy-devel-2.0.2-1.el6.x86_64.rpm

注意安装顺序 先安装libs 再安装pypy 最后安装devel

经测试 pypy的效率要比cpython高大约三到四倍

实现Python的交互模式下tab自动补全和vim下python tab自动补全:

下面是.pythonrc.py的内容

代码语言:javascript复制
try:
    import readline
except ImportError:
    print("Module readline not available.")
else:
    import rlcompleter
    readline.parse_and_bind("tab: complete")
代码语言:javascript复制
vim ~/.bashrc
export PYTHONSTARTUP=~/.pythonrc.py #加入此行

vim下:

代码语言:javascript复制
wget https://github.com/rkulla/pydiction/archive/master.zip 
unzip -q master
mv pydiction-master pydiction 
mkdir -p ~/.vim/tools/pydiction
cp -r pydiction/after ~/.vim 
cp pydiction/complete-dict ~/.vim/tools/pydiction

0 人点赞