vim 插件 (python) - 找不到 liburl2 模块



我正在使用python语言开发一个vim插件,步骤如下:http://brainacle.com/how-to-write-vim-plugins-with-python.html

我检查了一下:echo has('python')返回1,基本的python命令也能工作,但当我尝试导入上面链接中提到的"urlib2"模块时,它会抛出以下错误:

ImportError: No module named urllib2

另一方面,如果我创建一个简单的python程序,并尝试在其中导入urllib2,那么该程序运行良好。所以这个问题只存在于vim插件中。

我的vim安装细节:

VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Aug  9 2008 12:52:42)
MS-Windows 64-bit console version
Compiled by George@GEORGE-VPC1
Huge version without GUI.  Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent 
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments 
+cryptv +cscope +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic 
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path 
+float +folding -footer +gettext/dyn -hangul_input +iconv/dyn +insert_expand 
+jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap 
+menu +mksession +modify_fname +mouse -mouseshape +multi_byte_ime/dyn 
+multi_lang -mzscheme -netbeans_intg -osfiletype +path_extra -perl +postscript 
+printer +profile +python/dyn +quickfix +reltime +rightleft -ruby +scrollbind 
+signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary 
+tag_old_static -tag_any_white -tcl -tgetent -termresponse +textobjects +title 
-toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo 
+vreplace +wildignore +wildmenu +windows +writebackup -xfontset -xim 
-xterm_save -xpm_w32 
   system vimrc file: "$VIMvimrc"
   user vimrc file: "$HOME_vimrc"
  2nd user vimrc file: "$VIM_vimrc"
   user exrc file: "$HOME_exrc"
  2nd user exrc file: "$VIM_exrc"
Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32   -DFEAT_CSCOPE             -DWINVER=0x0400 -D_WIN32_WINNT=0x0400  /Fo.ObjCY/ /Ox /GL -DNDEBUG  /Zl /MT -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_MBYTE -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_PYTHON -DDYNAMIC_PYTHON  -DDYNAMIC_PYTHON_DLL="python25.dll" -DMSWINPS -DFEAT_HUGE /Fd.ObjCY/ /Zi
 Linking: link /RELEASE /nologo /subsystem:console /LTCG:STATUS oldnames.lib  kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:AMD64 /nodefaultlib  libcmt.lib   user32.lib     /nodefaultlib:python25.lib      /PDB:vim.pdb -debug

如何调试?

更新:我最近注意到这个错误是在我运行插件时抛出的:

'import site' failed; use -v for traceback

有关于如何调试的帮助吗?

对我来说,这个命令有效(没有错误):

:python import urllib2

Vim使用的Python解释器可能缺少一些库。通过检查导入路径

:python print sys.path

在我的系统上,它会打印以下内容:

['D:\must>not&exist', 'C:\Windows\system32\python27.zip', 'C:\Program
Files\Python\2.7\Lib', 'C:\Program Files\Python\2.7\DLLs',
'C:\Program Files\Python\2.7\Lib\lib-tk', 'D:\HOME\vimfiles\doc',
'c:\Program Files\vim\vim73', 'C:\Program Files\Python\2.7',
'C:\Program Files\Python\2.7\lib\site-packages']

最新更新