E887: Sorry, this command is disabled, the Python's site module could not be loaded.

2,526 views
Skip to first unread message

David Fishburn

unread,
Apr 6, 2015, 2:38:57 PM4/6/15
to vim_dev
I am trying to get Vim running with Python (I know nothing about Python).

I have gVim working with a dynamically loaded Perl.

I compile my own 32-bit Vim on Windows 7 64-bit.

D:\>python --version
Python 2.7

D:\>python
Python 2.7 (r27:82525, Jul  4 2010, 09:01:59) [MSC v.1500 32 bit (Intel)] on win 32
Type "help", "copyright", "credits" or "license" for more information.
>>>

D:\>which python
d:\python27\python.EXE



C:\OpenSrc\vim>"C:\Program Files\Mercurial\hg.exe" pull
searching for changes
adding changesets
adding manifests
adding file changes
added 35 changesets with 77 changes to 39 files
(run 'hg update' to get a working copy)

C:\OpenSrc\vim>"C:\Program Files\Mercurial\hg.exe" update
39 files updated, 0 files merged, 0 files removed, 0 files unresolved



I compile it the same way I compile with Perl:


***

IF NOT DEFINED VIM_PYTHON_VER SET VIM_PYTHON_VER=27
IF NOT DEFINED VIM_PYTHON_DIR SET VIM_PYTHON_DIR=D:\Python27
IF NOT DEFINED VIM_PERL_VER SET VIM_PERL_VER=516
IF NOT DEFINED VIM_PERL_DIR SET VIM_PERL_DIR=C:\Perl

nmake -f Make_mvc.mak debug=no gui=yes cscope=yes OLE=yes FEATURES=HUGE PYTHON=%VIM_PYTHON_DIR% DYNAMIC_PYTHON=yes PYTHON_VER=%VIM_PYTHON_VER% PERL=%VIM_PERL_DIR% DYNAMIC_PERL=yes PERL_VER=%VIM_PERL_VER% XPM=%VIM_XPM_DIR% 

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

Python requested (version 27) - root dir is "D:\Python27"
Python DLL will be loaded dynamically
Perl requested (version 516) - root dir is "C:\Perl"
Perl DLL will be loaded dynamically

...

  100%   0 seconds remaining
Finished generating code
        if exist gvim.exe.manifest mt.exe -nologo -manifest gvim.exe.manifest -u
pdateresource:gvim.exe;1
        cl /nologo -DNDEBUG vimrun.c
vimrun.c
        cl /nologo -DNDEBUG -DWIN32 dosinst.c kernel32.lib shell32.lib  user32.l
ib ole32.lib advapi32.lib uuid.lib
dosinst.c
        if exist install.exe del install.exe
        ren dosinst.exe install.exe
        cl /nologo -DNDEBUG -DWIN32 uninstal.c shell32.lib advapi32.lib
uninstal.c
        cd xxd
        "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe" /
NOLOGO -f Make_mvc.mak
        cl /nologo -DWIN32 xxd.c
xxd.c
        cd ..
        cd GvimExt
        "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\nmake.exe" /
NOLOGO -f Makefile
        cl -c -DCRTAPI1=_cdecl -DCRTAPI2=_cdecl -nologo -GS -D_X86_=1  -DWIN32 -
D_WIN32 -W3 -D_WIN32_IE=0x0400 -DWINVER=0x0400 -DFEAT_GETTEXT  -D_MT -MT gvimext
.cpp
gvimext.cpp
        Rc /r -DWIN32 -D_WIN32 -DWINVER=0x0400   gvimext.rc
Microsoft (R) Windows (R) Resource Compiler Version 6.1.7600.16385
Copyright (C) Microsoft Corporation.  All rights reserved.

        link  /INCREMENTAL:NO /NOLOGO -dll -def:gvimext.def -base:0x1C000000 -ou
t:gvimext.dll gvimext.obj gvimext.res ole32.lib uuid.lib oleaut32.lib kernel32.l
ib  ws2_32.lib mswsock.lib advapi32.lib user32.lib gdi32.lib comdlg32.lib winspo
ol.lib shell32.lib comctl32.lib
   Creating library gvimext.lib and object gvimext.exp
        if exist gvimext.dll.manifest mt -nologo -manifest gvimext.dll.manifest
-outputresource:gvimext.dll;2
        cd ..

***

I don't see any errors listed while compiling.



:ver
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr  6 2015 14:30:21)
MS-Windows 32-bit GUI version with OLE support
Included patches: 1-691
Compiled by me@myDomain
Huge version with GUI.  Features included (+) or not (-):
+acl             +clipboard       +cursorshape     +ex_extra        -hangul_input    +listcmds        +multi_lang      +profile         +smartindent     -tcl             +visual          -xim
+arabic          +cmdline_compl   +dialog_con_gui  +extra_search    +iconv/dyn       +localmap        -mzscheme        +python/dyn      -sniff           -tgetent         +visualextra     -xterm_save
+autocmd         +cmdline_hist    +diff            +farsi           +insert_expand   -lua             +netbeans_intg   -python3         +startuptime     -termresponse    +viminfo         +xpm_w32
+balloon_eval    +cmdline_info    +digraphs        +file_in_path    +jumplist        +menu            +ole             +quickfix        +statusline      +textobjects     +vreplace
+browse          +comments        -directx         +find_in_path    +keymap          +mksession       +path_extra      +reltime         -sun_workshop    +title           +wildignore
++builtin_terms  +conceal         -dnd             +float           +langmap         +modify_fname    +perl/dyn        +rightleft       +syntax          +toolbar         +wildmenu
+byte_offset     +cryptv          -ebcdic          +folding         +libcall         +mouse           +persistent_undo -ruby            +tag_binary      +user_commands   +windows
+cindent         +cscope          +emacs_tags      -footer          +linebreak       +mouseshape      -postscript      +scrollbind      +tag_old_static  +vertsplit       +writebackup
+clientserver    +cursorbind      +eval            +gettext/dyn     +lispindent      +multi_byte      +printer         +signs           -tag_any_white   +virtualedit     -xfontset
   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.\ObjGOLYi386/ /Ox /GL -DNDEBUG  /Zl /MT -
DFEAT_OLE -DFEAT_GUI_W32 -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_PYTHON -DDYNAMIC_PYTHON  -DDYNAMIC_PYTHON_DLL=\"python27.dll\" -DFEAT_PERL -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl516.dll\" -DFEAT_HUGE /Fd.
\ObjGOLYi386/ /Zi
Linking: link /RELEASE /nologo /subsystem:windows /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib uuid.lib /machine:i386 /nodefaultlib gdi32.lib version.lib
  winspool.lib comctl32.lib advapi32.lib shell32.lib  /machine:i386 /nodefaultlib libcmt.lib oleaut32.lib  user32.lib      /nodefaultlib:python27.lib     WSock32.lib xpm\x86\lib\libXpm.lib /PDB:gvim.pdb -debug



:echo has('perl') has('python') has('python3')
1 1 0

:python print 'anything'
E887: Sorry, this command is disabled, the Python's site module could not be loaded.



I have found only 1 reference to this error in vim_use or vim_dev:


Which is this:

Patch 7.4.380 
Problem:    Loading python may cause Vim to exit. 
Solution:   Avoid loading the "site" module. (Taro Muraoka) 
Files:            src/if_python.c 


Does anyone know what I might be doing wrong?

TIA,
David

Charles

unread,
Apr 6, 2015, 11:01:09 PM4/6/15
to vim_dev
On Tue, Apr 7, 2015 at 1:38 AM, David Fishburn <dfishb...@gmail.com> wrote:
> :python print 'anything'
> E887: Sorry, this command is disabled, the Python's site module could not be
> loaded.

Try adding the environment variable PYTHON_HOME=D:\Python27

Yukihiro Nakadaira

unread,
Apr 7, 2015, 12:43:54 AM4/7/15
to vim...@googlegroups.com
On Tue, Apr 7, 2015 at 3:38 AM, David Fishburn <dfishb...@gmail.com> wrote:
:echo has('perl') has('python') has('python3')
1 1 0

:python print 'anything'
E887: Sorry, this command is disabled, the Python's site module could not be loaded.



I have found only 1 reference to this error in vim_use or vim_dev:


Which is this:

Patch 7.4.380 
Problem:    Loading python may cause Vim to exit. 
Solution:   Avoid loading the "site" module. (Taro Muraoka) 
Files:            src/if_python.c 


Does anyone know what I might be doing wrong?

Check result of "where python27.dll" in command prompt.
I guess that Mercurial's python27.dll is found before Python's python27.dll.

--
Yukihiro Nakadaira - yukihiro....@gmail.com

David Fishburn

unread,
Apr 7, 2015, 1:39:16 PM4/7/15
to vim_dev
I have tried:

PYTHON_HOME=D:\Python27


D:\>SET PY
PYTHON_HOME=D:\Python27

D:\>dir %PYTHON_HOME%
 Volume in drive D is D
 Volume Serial Number is FC7C-B353

 Directory of D:\Python27

07/04/2015  07:58 AM    <DIR>          DLLs
18/07/2014  04:43 PM    <DIR>          Doc
18/07/2014  04:43 PM    <DIR>          include
06/04/2015  10:54 AM    <DIR>          Lib
18/07/2014  04:44 PM    <DIR>          libs
18/07/2014  04:44 PM    <DIR>          Scripts
18/07/2014  04:44 PM    <DIR>          tcl
18/07/2014  04:44 PM    <DIR>          Tools
...
04/07/2010  09:03 AM            26,624 python.exe
04/07/2010  09:04 AM            27,136 pythonw.exe
04/07/2010  07:32 AM            54,958 README.txt
04/07/2010  09:01 AM            49,664 w9xpopen.exe
               6 File(s)        438,119 bytes
              10 Dir(s)  174,812,467,200 bytes free

D:\>gvim

:python print 'anything'
E887: Sorry, this command is disabled, the Python's site module could not be loaded.


D:\>where python27.dll
C:\Windows\System32\python27.dll
C:\Program Files\Mercurial\python27.dll

Using Explorer and checking properties on C:\Windows\System32\python27.dll 
I see file Version:
2.7.3150.1013

The C:\Program Files\Mercurial\python27.dll has a file version of:
2.7.4150.1013



Trying this:

D:\>SET PATH=C:\Program Files\Mercurial;%PATH%
D:\>gvim

:python print 'anything'
E887: Sorry, this command is disabled, the Python's site module could not be loaded.



Any other suggestions?

TIA,
David


Ben Fritz

unread,
Apr 7, 2015, 4:51:56 PM4/7/15
to vim...@googlegroups.com
One sanity check, from within Vim, make sure your python paths match what you expect from your earlier test in your shell:

:!where python27.dll

Next step, maybe install a more recent python?

Yours just shows "Python 2.7" whereas mine (which has been working fine for a long time) shows "Python 2.7.6". I think the 2.7.x series is supposed to maintain backwards compatibility with any other 2.7.x version, unlike Python 3.

David Fishburn

unread,
Apr 8, 2015, 9:20:43 AM4/8/15
to vim_dev
I have it working now, Ben your suggestion of updating my 2.7 version seems to have worked.  I upgraded to 2.7.9.

I had some incorrect information above:

On 64-bit Windows, 32-bit DLLs are installed in C:\Windows\SysWOW64, not C:\Windows\System32

C:\Windows\SysWOW64\python27.dll
Shows a file version of: 2.7.9150.1013
Shows a product version of: 2.7.9

I recompiled my Vim just in case:

:ver
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr  8 2015 09:09:46)
MS-Windows 32-bit GUI version with OLE support
Included patches: 1-691

:python print 'anything'
anything

:echo has('perl') has('python') has('python3')
1 1 0


Thanks everyone for the responses, much appreciated.

David



Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages