VIM 配置及内核代码编译

1. 编译安装python

1.1 下载 python 源代码

$wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
$tar -zxvf Python-3.6.5.tgz; cd Python-3.6.5/

1.2 安装 zlib 相关依赖

$sudo yum -y install zlib*

1.3 配置生成 makefile

$./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" --enable-unicode=ucs4 --enable-optimizations

1.4 编译安装 python

$make
$sudo make altinstall 
$sudo ln -sv /usr/local/bin/python3.6 /usr/local/bin/python
$sudo unlink /usr/bin/python; sudo ln -sv /usr/local/bin/python /usr/bin/python
$sudo unlink /home/tops/bin/python; sudo ln -sv /usr/local/bin/python /home/tops/bin/python

升级 python 之后可能会因为语法不一致导致依赖于旧版本 python 的软件工作不正常

例如运行 yum 可能会出现如下错误

$ yum 
File "/usr/bin/yum", line 30 
except KeyboardInterrupt, e: 
SyntaxError: invalid syntax

解决的办法:

1. 升级 yum

2. 或者修改 yum 使用的语法解释器

修改 #!/usr/bin/python 为 #!/usr/bin/python2.7

3. 在编译VIM之后把 /home/tops/bin/python 软连接回 python2.7

#Sctipt to switch to python 3
$cat ~/rain/p3.sh
 
sudo unlink /home/tops/bin/python
sudo ln -sv /usr/local/bin/python /home/tops/bin/python
ls -al /home/tops/bin/python
 
sudo unlink /usr/bin/python•
sudo ln -sv /usr/local/bin/python /usr/bin/python•
ls -al /usr/bin/python
 
#################################
 
#Sctipt to switch to python 2
$cat ~/rain/p2.sh
 
sudo mv /home/tops/bin/python /home/tops/bin/python-bak
sudo ln -sv /home/tops/bin/python2 /home/tops/bin/python
ls -al /home/tops/bin/python
 
sudo mv /usr/bin/python /usr/bin/python-bak•
sudo ln -sv /usr/bin/python2 /usr/bin/python•
ls -al /usr/bin/python

2. 编译安装VIM

2.1 安装相关依赖,如果可以直接安装 python可以省去前面编译过程

VIM 配置及内核代码编译

相关推荐