Search code examples
pythonpython-2.7installationvim

Vim unable to find Python27.dll on startup but I'm on Python3.11


I'm looking to get comfortable with vim and I set up my system according to these two tutorials.

https://realpython.com/vim-and-python-a-match-made-in-heaven/ https://github.com/VundleVim/Vundle.vim/wiki/Vundle-for-Windows

I have Vim in program files (x86) and vundle in \vimfiles\bundle.

My _vimrc script looks like this:

filetype off
set shellslash
set rtp+=~/vimfiles/bundle/Vundle.vim
call vundle#begin('C:/Users/mshen/vimfiles/bundle')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'tmhedberg/SimpylFold'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'vim-syntastic/syntastic'
Plugin 'nvie/vim-flake8'
Plugin 'jnurmine/Zenburn'
Plugin 'altercation/vim-colors-solarized'
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'Lokaltog/powerline', {'rtp': 'powerline/bindings/vim/'}

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

set splitbelow
set splitright
"split navigations
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

" Enable folding
set foldmethod=indent
set foldlevel=99

" Enable folding with the spacebar
nnoremap <space> za

au BufNewFile,BufRead *.py
    \ set tabstop=4
    \ set softtabstop=4
    \ set shiftwidth=4
    \ set textwidth=79
    \ set expandtab
    \ set autoindent
    \ set fileformat=unix

au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/

py << EOF
import os
import sys
if 'VIRTUAL_ENV' in os.environ:
  project_base_dir = os.environ['VIRTUAL_ENV']
  activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
  execfile(activate_this, dict(__file__=activate_this))
EOF

let python_highlight_all=1
syntax on

call togglebg#map("<F5>")

let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree

set nu

set clipboard=unnamed
set editing-mode vi

"default _vimrc below 
"...

When I try to run Vim (from shortcut or powershell $vim), it gives me the following error:

Vim startup error

Why is this thing looking for python27?

Thanks!

I know the plugins are properly installed. I know that the line numbering works. I'm not familiar with vim enough to know how to access the other plugins.

My python is 64 bit, but I don't think 32 vs 64 mismatch is causing the error because either way, I don't have python27 and don't know why vim wants it instead of the latest release.


Solution

  • You'll need to change your vimrc to use :python3 and :py3 instead of :python and :py.

    For example, in this line:

    py << EOF
    import os
    ...
    

    Update that to

    py3 << EOF
    import os
    ...
    

    The "VIM and Python – A Match Made in Heaven" is a great article, but it's also kinda outdated as it was last updated at 2018-06-01.