【发布时间】:2013-12-10 11:47:37
【问题描述】:
我正在使用这里提到的步骤用 python 语言开发一个 vim 插件:http://brainacle.com/how-to-write-vim-plugins-with-python.html
我检查了 :echo has('python') 返回 1 并且基本的 python 命令可以工作,但是当我尝试导入上面链接中提到的“urllib2”模块时,它会抛出以下错误:
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: "$VIM\vimrc"
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
关于如何调试的任何帮助?
【问题讨论】:
-
您确定没有将 liburl2 与 urllib2 混淆吗?
-
是的,我打错了,但后来更正了... urllib2 不适合我...感谢您指出这一点:p
-
您是否安装了多个版本的 Python?通过执行
:python import sys; print sys.version来检查 Vim 使用的是哪一个。