I want to use a certain python interpreter instead of an installed one.

My gvim version is

VIM - Vi IMproved 8.2 (2019 Dec 12 kompiliert am Dec 12 2019 13:30:17)
MS-Windows 32 Bit GUI Version mit OLE-Unterstützung
Übersetzt von mool@tororo
Riesige Version mit GUI. Ein- (+) oder ausschließlich (-) der Eigenschaften:
+acl                +eval               +multi_lang         -tag_any_white
+arabic             +ex_extra           +mzscheme/dyn       +tcl/dyn
+autocmd            +extra_search       +netbeans_intg      -termguicolors
+autochdir          -farsi              +num64              +terminal
+autoservername     +file_in_path       +ole                -termresponse
+balloon_eval       +find_in_path       +packages           +textobjects
-balloon_eval_term  +float              +path_extra         +textprop
+browse             +folding            +perl/dyn           -tgetent
++builtin_terms     -footer             +persistent_undo    +timers
+byte_offset        +gettext/dyn        +popupwin           +title
+channel            -hangul_input       -postscript         +toolbar
+cindent            +iconv/dyn          +printer            +user_commands
+clientserver       +insert_expand      +profile            +vartabs
+clipboard          +job                +python/dyn         +vertsplit
+cmdline_compl      +jumplist           +python3/dyn        +virtualedit
+cmdline_hist       +keymap             +quickfix           +visual
+cmdline_info       +lambda             +reltime            +visualextra
+comments           +langmap            +rightleft          +viminfo
+conceal            +libcall            +ruby/dyn           +vreplace
+cryptv             +linebreak          +scrollbind         -vtp
+cscope             +lispindent         +signs              +wildignore
+cursorbind         +listcmds           +smartindent        +wildmenu
+cursorshape        +localmap           +sound              +windows
+dialog_con_gui     +lua/dyn            +spell              +writebackup
+diff               +menu               +startuptime        -xfontset
+digraphs           +mksession          +statusline         -xim
+directx            +modify_fname       -sun_workshop       +xpm_w32
-dnd                +mouse              +syntax             -xterm_save
-ebcdic             +mouseshape         +tag_binary         
+emacs_tags         +multi_byte_ime/dyn -tag_old_static     
          System-vimrc-Datei: "$VIM\vimrc"
        Benutzer-vimrc-Datei: "$HOME\_vimrc"
 zweite Benutzer-vimrc-Datei: "$HOME\vimfiles\vimrc"
 dritte Benutzer-vimrc-Datei: "$VIM\_vimrc"
         Benutzer-exrc-Datei: "$HOME\_exrc"
 zweite Benutzer-exrc-Datei: "$VIM\_exrc"
         System-gvimrc-Datei: "$VIM\gvimrc"
       Benutzer-gvimrc-Datei: "$HOME\_gvimrc"
zweite Benutzer-gvimrc-Datei: "$HOME\vimfiles\gvimrc"
dritte Benutzer-gvimrc-Datei: "$VIM\_gvimrc"
      defaults Datei: "$VIMRUNTIME\defaults.vim"
           System-Menü-Datei: "$VIMRUNTIME\menu.vim"
Linken: link  /nologo /opt:ref /LTCG:STATUS oldnames.lib kernel32.lib advapi32.lib shell32.lib gdi32.lib  comdlg32.lib ole32.lib netapi32.lib uuid.lib /machine:i386 gdi32.lib version.lib   winspool.lib comctl32.lib advapi32.lib shell32.lib netapi32.lib  /machine:i386  libcmt.lib oleaut32.lib user32.lib  /nodefaultlib:lua53.lib  /STACK:8388608  /nodefaultlib:python27.lib /nodefaultlib:python36.lib   "E:\ActiveTcl\lib\tclstub86.lib" winmm.lib WSock32.lib xpm\x86\lib-vc14\libXpm.lib /PDB:gvim.pdb -debug

So it has support for python3/dyn.

If I start gvim naked with:

gvim -Nu NONE

and try to run python3 like this

:py3 import sys;print(sys.version)

I get E370: unable to load python36.dll

which seems to be the default python version.

Now I can fix this by setting pythonthreehome and pythonthreedll to an installed python version:

:set pythonthreehome=c:\Users\ws\Anaconda3\
:set pythonthreedll=c:\Users\ws\Anaconda3\python38.dll


:py3 import sys;print(sys.version)

now shows me python 3.8.3 is used.

But if I want to use another python3, which is not installed, but instead checked out from a repository, like this

:set pythonthreehome=c:\installations\cs_workspaces4_trunk\trunk\libs\Python35\
:set pythonthreedll=c:\installations\cs_workspaces4_trunk\trunk\libs\Python35\python35.dll

and try to run py3 again, I get

E448: (translated from german) Could not load library function PySlice_AdjustIndices


E263: (translated from german) Sorry, this command is disabled, the Python library could not be loaded

Can anyone tell me if and how it is possible to use a python3 interpreter dll in vim from a python which is not installed?

  • No, you cannot switch to a different python library, once it had been loaded. Simply start a new vim session if you need this Sep 30, 2020 at 13:34
  • 1
    Thanx for your reply. Starting a new session would be ok. But this does not work either. I have found no way to make vim use the aforementioned 3.5 installation.
    – slash
    Sep 30, 2020 at 14:33

1 Answer 1


The C API of Python evolves with the version of Python. In this case, function PySlice_AdjustIndices was introduced in this commit to supercede function PySlice_GetIndicesEx, but it seems this function was only released starting with Python 3.5.4 and 3.6.1.

Since your Vim seems to default to pythonthreedll=python36.dll (inferred from error message E370: unable to load python36.dll), it seems it was compiled against a Python 3.6, and since it's mentioning that particular function, I'm assuming it was Python 3.6.1 or later.

On the other hand, it seems your Python 3.5 from the separate installation might be 3.5.3 or earlier, since it seems to be missing that particular function (given the error message E448: (translated from german) Could not load library function PySlice_AdjustIndices).

So, the problem isn't really that it's not possible to use a separate installation of Python with your Vim... But that that separate installation of Python needs to match the one used when Vim was compiled.

The C API of Python is typically backwards compatible, so later versions of Python will typically work (as you noticed, and reported that Anaconda3\python38.dll works.) But older versions might not work in cases like the one you encountered.

You might be able to work around this particular issue by upgrading your separate installation of Python to 3.5.4 or later, which should include the PySlice_AdjustIndices function, but it's quite possible you might then bump into a similar issue with a different function. Safer would be to stick with a later version of Python if you can.

  • 1
    This explanation makes sense to me. Using different python versions works in principle, however the python3 version must satisfy minimum version requirements. I verified this - indeed I can use another, not installed python dll, if the version ist sufficient. Thanx!
    – slash
    Oct 1, 2020 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.