我一直在努力使powerline工作一段时间,但似乎无法弄清楚出什么问题了。我经常在tmux内部使用vim,但是在tmux内部和外部的错误是相同的。
这是我调用vim时遇到的错误:
$ vim
Error detected while processing /Users/jlconlin/.vim/powerline.vim:
line 4:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named powerline.vim
line 5:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'powerline_setup' is not defined
line 6:
Traceback (most recent call last):
File "<string>", line 1, in <module>
NameError: name 'powerline_setup' is not defined
Press ENTER or type command to continue
我的猜测是Vim不知道在哪里寻找python软件包/模块,但是我不知道如何告诉Vim该做什么。我已经通过Google进行了广泛搜索(包括stackexchange),但没有找到解决方案。
在我的.vimrc
文件中,我有:
set rtp+=$POWERLINE_ROOT/powerline/bindings/vim
let g:pymcd_powerline="py3"
python from powerline.vim import setup as powerline_setup
python powerline_setup()
python del powerline_setup
POWERLINE_ROOT
是通过命令设置的
POWERLINE_ROOT=$(pip show powerline-status | sed -n 's/Location: \(.*\)/\1/p')
我已经用anaconda发行版安装了Python3,并且已经用pip安装了电力线:
$ pip show po werline-status
Name: powerline-status
Version: 2.7
Summary: The ultimate statusline/prompt utility.
Home-page: https://github.com/powerline/powerline
Author: Kim Silkebaekken
Author-email: kim.silkebaekken+vim@gmail.com
License: MIT
Location: /Users/jlconlin/opt/anaconda3/lib/python3.7/site-packages
Requires:
Required-by
我使用MacVim(它同时支持python和python3),并为我的终端vim使用内部版本:
$ which vim
/Applications/MacVim.app/Contents/MacOS/vim
$ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Oct 30 2019 11:57:56)
macOS version
Included patches: 1-2234
Compiled by travis@Traviss-Mac.local
Huge version with MacVim GUI. Features included (+) or not (-):
+acl +file_in_path +mouse_urxvt -tcl
+arabic +find_in_path +mouse_xterm +termguicolors
+autocmd +float +multi_byte +terminal
+autochdir +folding +multi_lang +terminfo
-autoservername -footer -mzscheme +termresponse
+balloon_eval +fork() +netbeans_intg +textobjects
+balloon_eval_term +fullscreen +num64 +textprop
+browse -gettext +odbeditor +timers
++builtin_terms -hangul_input +packages +title
+byte_offset +iconv +path_extra +toolbar
+channel +insert_expand +perl/dyn +transparency
+cindent +job +persistent_undo +user_commands
+clientserver +jumplist +postscript +vartabs
+clipboard +keymap +printer +vertsplit
+cmdline_compl +lambda +profile +virtualedit
+cmdline_hist +langmap +python/dyn +visual
+cmdline_info +libcall +python3/dyn +visualextra
+comments +linebreak +quickfix +viminfo
+conceal +lispindent +reltime +vreplace
+cryptv +listcmds +rightleft +wildignore
+cscope +localmap +ruby/dyn +wildmenu
+cursorbind +lua/dyn +scrollbind +windows
+cursorshape +menu +signs +writebackup
+dialog_con_gui +mksession +smartindent -X11
+diff +modify_fname -sound -xfontset
+digraphs +mouse +spell +xim
+dnd +mouseshape +startuptime -xpm
-ebcdic +mouse_dec +statusline -xsmp
+emacs_tags -mouse_gpm -sun_workshop -xterm_clipboard
+eval -mouse_jsbterm +syntax -xterm_save
+ex_extra +mouse_netterm +tag_binary
+extra_search +mouse_sgr -tag_old_static
-farsi -mouse_sysmouse -tag_any_white
system vimrc file: "$VIM/vimrc"
user vimrc file: "$HOME/.vimrc"
2nd user vimrc file: "~/.vim/vimrc"
user exrc file: "$HOME/.exrc"
system gvimrc file: "$VIM/gvimrc"
user gvimrc file: "$HOME/.gvimrc"
2nd user gvimrc file: "~/.vim/gvimrc"
defaults file: "$VIMRUNTIME/defaults.vim"
system menu file: "$VIMRUNTIME/menu.vim"
fall-back for $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe -DMACOS_X -DMACOS_X_DARWIN -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L/usr/local/lib -o Vim -framework Cocoa -framework Carbon -lm -lncurses -liconv -framework AppKit -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE