注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

God is U 做自己的上帝

富原孤島--只发优质级的文章

 
 
 

日志

 
 

Centos7配置vim支持python3  

2017-12-20 11:39:41|  分类: [LINUX] |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
一、查看vim版本和对python的支持,(默认Centos7.4的vim是7.4版,且不支持python2和python3)

[root@iZwz96ioq7k0wp5bguxmcgZ opt]# vi --version |grep -E 'VIM|python'
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 2 2017 00:45:54)
-comments -langmap -python -viminfo
-conceal -libcall -python3 -vreplace
fall-back for $VIM: "/etc"
f-b for $VIMRUNTIME: "/usr/share/vim/vim74"
[root@iZwz96ioq7k0wp5bguxmcgZ opt]#

二、下载和重新编译VIM8 (注,Make有2个错误没时间去解决,直接使用了7.4版本,此处记录)

[root@iZwz96ioq7k0wp5bguxmcgZ opt]# wget ftp://ftp.vim.org/pub/vim/unix/vim-8.0.tar.bz2

--2017-12-20 10:33:59-- ftp://ftp.vim.org/pub/vim/unix/vim-8.0.tar.bz2
=> ‘vim-8.0.tar.bz2’
Resolving ftp.vim.org (ftp.vim.org)... 145.220.21.40, 2001:67c:6ec:221:145:220:21:40
Connecting to ftp.vim.org (ftp.vim.org)|145.220.21.40|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD (1) /pub/vim/unix ... done.
==> SIZE vim-8.0.tar.bz2 ... 10866752
==> PASV ... done. ==> RETR vim-8.0.tar.bz2 ... done.
Length: 10866752 (10M) (unauthoritative)

100%[========================================================================================>] 10,866,752 1.89MB/s in 8.9s

2017-12-20 10:34:13 (1.16 MB/s) - ‘vim-8.0.tar.bz2’ saved [10866752]

[root@iZwz96ioq7k0wp5bguxmcgZ opt]# wget ftp://ftp.vim.org/pub/vim/unix/vim-8.0.tar.bz2
--2017-12-20 10:33:59-- ftp://ftp.vim.org/pub/vim/unix/vim-8.0.tar.bz2
=> ‘vim-8.0.tar.bz2’
Resolving ftp.vim.org (ftp.vim.org)... 145.220.21.40, 2001:67c:6ec:221:145:220:21:40
Connecting to ftp.vim.org (ftp.vim.org)|145.220.21.40|:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD (1) /pub/vim/unix ... done.
==> SIZE vim-8.0.tar.bz2 ... 10866752
==> PASV ... done. ==> RETR vim-8.0.tar.bz2 ... done.
Length: 10866752 (10M) (unauthoritative)

100%[========================================================================================>] 10,866,752 1.89MB/s in 8.9s

2017-12-20 10:34:13 (1.16 MB/s) - ‘vim-8.0.tar.bz2’ saved [10866752]

[root@iZwz96ioq7k0wp5bguxmcgZ opt]# chmod 755 vim-8.0.tar.bz2

[root@iZwz96ioq7k0wp5bguxmcgZ opt]# tar -xjvf vim-8.0.tar.bz2

//如果报bzip2: Cannot exec错误则检查一下,rpm -qa bzip2,没有则yum install bzip2

[root@iZwz96ioq7k0wp5bguxmcgZ opt]# cd vim80/src/
[root@iZwz96ioq7k0wp5bguxmcgZ src]# vi Makefile
//查找
OPT_PYTHON3

# PYTHON
# Uncomment lines here when you want to include the Python interface.
# This requires at least "normal" features, "tiny" and "small" don't work.
# NOTE: This may cause threading to be enabled, which has side effects (such
# as using different libraries and debugging becomes more difficult).
# For Python3 support make a symbolic link in /usr/local/bin:
# ln -s python3 python3.1
# If both python2.x and python3.x are enabled then the linking will be via
# dlopen(), dlsym(), dlclose(), i.e. pythonX.Y.so must be available
# However, this may still cause problems, such as "import termios" failing.
# Build two separate versions of Vim in that case.
CONF_OPT_PYTHON = --enable-pythoninterp
#CONF_OPT_PYTHON = --enable-pythoninterp=dynamic
CONF_OPT_PYTHON3 = --enable-python3interp
#CONF_OPT_PYTHON3 = --enable-python3interp=dynamic

[root@iZwz96ioq7k0wp5bguxmcgZ src]# make //有2个错误,暂时不用这个版本

三、下载和重新编译VIM7.4

[root@iZwz96ioq7k0wp5bguxmcgZ opt]# wget ftp://ftp.vim.org/pub/vim/unix/vim-7.4.tar.bz2

[root@iZwz96ioq7k0wp5bguxmcgZ opt]# cd vim74/src
[root@iZwz96ioq7k0wp5bguxmcgZ src]# cat Makefile |grep OPT_PYTHON
# (U) Must uncomment CONF_OPT_PYTHON option below to disable Python
#CONF_OPT_PYTHON = --enable-pythoninterp
#CONF_OPT_PYTHON = --enable-pythoninterp=dynamic
#CONF_OPT_PYTHON3 = --enable-python3interp
#CONF_OPT_PYTHON3 = --enable-python3interp=dynamic
$(CONF_OPT_PERL) $(CONF_OPT_PYTHON) $(CONF_OPT_PYTHON3) \
[root@iZwz96ioq7k0wp5bguxmcgZ src]# vi Makefile
[root@iZwz96ioq7k0wp5bguxmcgZ src]# cat Makefile |grep OPT_PYTHON
# (U) Must uncomment CONF_OPT_PYTHON option below to disable Python
#CONF_OPT_PYTHON = --enable-pythoninterp
#CONF_OPT_PYTHON = --enable-pythoninterp=dynamic
#CONF_OPT_PYTHON3 = --enable-python3interp
CONF_OPT_PYTHON3 = --enable-python3interp
#CONF_OPT_PYTHON3 = --enable-python3interp=dynamic
$(CONF_OPT_PERL) $(CONF_OPT_PYTHON) $(CONF_OPT_PYTHON3) \
[root@iZwz96ioq7k0wp5bguxmcgZ src]# make

[root@iZwz96ioq7k0wp5bguxmcgZ src]# ./vim --version |grep python //make install前验证是否包含py3
+cryptv +linebreak -python +viminfo
-cscope +lispindent +python3 +vreplace
Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lm -ltinfo -lnsl -lselinux -ldl -L/usr/local/lib/python3.6/config-3.6m-x86_64-linux-gnu -lpython3.6m -lpthread -ldl -lutil -lm
[root@iZwz96ioq7k0wp5bguxmcgZ src]# make install

[root@iZwz96ioq7k0wp5bguxmcgZ src]# ./vim

注:为方便使用,可将所有当前vim/vi的链接(/usr/bin/vi 和/usr/local/bin/vi)指向上述vim
四、配置python3,(直接修改~/.vimrc,添加以下,就可以实现高亮,和按F5执行程序)

[root@iZwz96ioq7k0wp5bguxmcgZ ~]# vim .vimrc
  "enable syntax highlighting
syntax enable

" show line numbers
set number

" set tabs to have 4 spaces
set ts=4

" indent when moving to the next line while writing code
set autoindent

" expand tabs into spaces
set expandtab

" when using the >> or << commands, shift lines by 4 spaces
set shiftwidth=4

" show a visual line under the cursor's current line
set cursorline

" show the matching part of the pair for [] {} and ()
set showmatch

" enable all Python syntax highlighting features
let python_highlight_all = 1

" run python for F5
au BufRead *.py map <buffer> <F5> :w<CR>:!/usr/bin/env python % <CR>
                               
~                                                                                                        

                                      

  评论这张
 
阅读(35)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018