2018年(273)
分类: 大数据
2018-06-29 15:36:33
$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/
$sudo yum -y install zlib*
$./configure --prefix=/usr/local --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib" --enable-unicode=ucs4 --enable-optimizations
$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
$sudo yum install lua lua-devel –y $sudo yum install ncurses-devel $sudo yum install -y ruby ruby-devel lua lua-devel luajit uajit-devel ctags git python python-devel python3 python3-devel tcl-devel perl perl-devel perl-ExtUtils-ParseXS perl-ExtUtils-XSpp perl-ExtUtils-CBuilder perl-ExtUtils-Embed
sudo yum remove vim vim-runtime gvim
$git clone https://github.com/vim/vim.git; cd vim
$./configure --enable-multibyte --enable-perlinterp=yes --enable-rubyinterp=yes --enable-python3interp=yes --enable-luainterp=yes --enable-gui=auto --enable-cscope --disable-selinux --with-features=huge --prefix=/usr/local
如果编译之后的 VIM 版本信息里面不包含 +python3,可以尝试添加 Python3 配置路径