windows vim “:py 导入套接字” returns "load dll failed: method not found"

windows vim ":py import socket" returns "load dll failed: method not found"

我有一个 vim74 便携版 (win32):

 VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 10 2013 14:38:33)
MS-Windows 32-bit GUI version with OLE support
Compiled by mool@tororo
Big version with GUI.  Features included (+) or not (-):
+arabic             +ex_extra           +mouseshape         +syntax
+autocmd            +extra_search       +multi_byte_ime/dyn +tag_binary
+balloon_eval       +farsi              +multi_lang         +tag_old_static
+browse             +file_in_path       -mzscheme           -tag_any_white
++builtin_terms     +find_in_path       +netbeans_intg      +tcl/dyn
+byte_offset        +float              +ole                -tgetent
+cindent            +folding            +path_extra         -termresponse
+clientserver       -footer             +perl/dyn           +textobjects
+clipboard          +gettext/dyn        +persistent_undo    +title
+cmdline_compl      -hangul_input       -postscript         +toolbar
+cmdline_hist       +iconv/dyn          +printer            +user_commands
+cmdline_info       +insert_expand      -profile            +vertsplit
+comments           +jumplist           +python/dyn         +virtualedit
+conceal            +keymap             +python3/dyn        +visual
+cryptv             +langmap            +quickfix           +visualextra
+cscope             +libcall            +reltime            +viminfo
+cursorbind         +linebreak          +rightleft          +vreplace
+cursorshape        +lispindent         +ruby/dyn           +wildignore
+dialog_con_gui     +listcmds           +scrollbind         +wildmenu
+diff               +localmap           +signs              +windows
+digraphs           -lua                +smartindent        +writebackup
-dnd                +menu               -sniff              -xfontset
-ebcdic             +mksession          +startuptime        -xim
+emacs_tags         +modify_fname       +statusline         -xterm_save
+eval               +mouse              -sun_workshop       +xpm_w32
   system vimrc file: "$VIM\vimrc"
     user vimrc file: "$HOME\_vimrc"
 2nd user vimrc file: "$HOME\vimfiles\vimrc"
 3rd user vimrc file: "$VIM\_vimrc"
      user exrc file: "$HOME\_exrc"
  2nd user exrc file: "$VIM\_exrc"
  system gvimrc file: "$VIM\gvimrc"
    user gvimrc file: "$HOME\_gvimrc"
2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
3rd user gvimrc file: "$VIM\_gvimrc"
    system menu file: "$VIMRUNTIME\menu.vim"
Compilation: cl -c /W3 /nologo  -I. -Iproto -DHAVE_PATHDEF -DWIN32   -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG   
-DFEAT_XPM_W32   -DWINVER=0x0400 -D_WIN32_WINNT=0x0400  /Fo.\ObjGOLYHTRi386/ /Ox /GL -DNDEBUG  /Zl /MT 
-DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_GUI_W32 -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT 
-DFEAT_TCL -DDYNAMIC_TCL -DDYNAMIC_TCL_DLL=\"tcl85.dll\" -DDYNAMIC_TCL_VER=\"8.5\" -DFEAT_PYTHON 
-DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PYTHON3 -DDYNAMIC_PYTHON3 
-DDYNAMIC_PYTHON3_DLL=\"python32.dll\" -DFEAT_PERL -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl514.dll\" 
-DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=19 -DDYNAMIC_RUBY_DLL=\"msvcrt-ruby192.dll\" -DFEAT_BIG 
/Fd.\ObjGOLYHTRi386/ /Zi
Linking: link /RELEASE /nologo /subsystem:windows /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib 

Python 2.7.9 已安装,%path% 包含 python27.dll.

的路径

命令“:py print 2+2”returns 4 但“:py import socket”returns 错误:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\python27\Lib\socket.py", line 47, in <module> 
    import _socket
ImportError: DLL load failed: method not found

命令“:!python -c "import socket"”没有任何错误。

怎么了?我该如何解决这个错误? 谢谢解答!

我通过将 python 的文件(python27.dll、python.exe、pythonw.exe)复制到 vim 应用程序文件夹(有vim.exe、gvim.exe、diff.exe等文件)。

祝你好运,不要忘记从 python 文件夹中删除 msvcrt90.dll 或从 %path% 变量中删除 python 文件夹的路径 ;)