Python-mode: Error when using python3 with MacVim

Created on 24 May 2018  路  5Comments  路  Source: python-mode/python-mode

I'm using macvim on macOS, the macvim is updated to the latest version with python3 support. When I open a python file, I got the below error in vim:

Error detected while processing function pymode#init:
line 2:
E837: This Vim cannot execute :py3 after using :python
E263: Sorry, this command is disabled, the Python library could not be loaded.
line 3:
E837: This Vim cannot execute :py3 after using :python
E263: Sorry, this command is disabled, the Python library could not be loaded.
line 4:
E837: This Vim cannot execute :py3 after using :python
E263: Sorry, this command is disabled, the Python library could not be loaded.
Error detected while processing /Users/chao/.vim/bundle/python-mode/autoload/pymode/virtualenv.vim:
line 3:
E837: This Vim cannot execute :py3 after using :python
E263: Sorry, this command is disabled, the Python library could not be loaded.
Error detected while processing function pymode#breakpoint#init:
line 21:
E837: This Vim cannot execute :py3 after using :python
E263: Sorry, this command is disabled, the Python library could not be loaded.
Error detected while processing /Users/chao/.vim/bundle/python-mode/ftplugin/python/pymode.vim:
line 25:
E837: This Vim cannot execute :py3 after using :python
E263: Sorry, this command is disabled, the Python library could not be loaded.

I already set the python mode in vim.rc let g:pymode_python = 'python3'. How could I fix it? Is there some configurations I need to set or is there some plugin still using python2?
Thanks a lot!

waiting

Most helpful comment

I had the same problem with latest MacVim installed via homebrew-cask. Then I changed to brew version of MacVim and this issue is fixed.

The minimal vimrc file is:

call plug#begin()
Plug 'Valloric/YouCompleteMe', { 'do': '/usr/local/bin/python3 install.py' }
Plug 'python-mode/python-mode', { 'for': 'python' }
call plug#end()

let g:pymode_python = 'python3'
let g:pymode_rope = 0

The cask version of MacVim is compiled with both python2 and python3 support and maybe YouCompleteMe always runs python2 for its client by default. But the brew version is only compiled with python3.

All 5 comments

cat >> ~/.vimrc << EOF
" Disable virtualenv in Pymode
let g:pymode_virtualenv = 0
" Disable pymode init and lint because of https://github.com/python-mode/python-mode/issues/897
let g:pymode_init = 0
let g:pymode_lint = 0

Any other plugin were you using? It seems like that some other plugin had the Python2 loaded before the functions is pymode were called, most possibly some plugin has statements like has('python') which have vim load the Python library. You could try to disable all the other plugins that use Python as extension, if the problem is gone, then enable the suspected plugins one by one to determine which exactly causes the issue.

I had the same problem with latest MacVim installed via homebrew-cask. Then I changed to brew version of MacVim and this issue is fixed.

The minimal vimrc file is:

call plug#begin()
Plug 'Valloric/YouCompleteMe', { 'do': '/usr/local/bin/python3 install.py' }
Plug 'python-mode/python-mode', { 'for': 'python' }
call plug#end()

let g:pymode_python = 'python3'
let g:pymode_rope = 0

The cask version of MacVim is compiled with both python2 and python3 support and maybe YouCompleteMe always runs python2 for its client by default. But the brew version is only compiled with python3.

Hi all, any news here?
Can I close the issue? (I'll wait for a week ok?)

@diraol Please close. It works now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zeraus picture zeraus  路  11Comments

kryptek picture kryptek  路  10Comments

lyneca picture lyneca  路  4Comments

randomizedthinking picture randomizedthinking  路  7Comments

Ins1ne picture Ins1ne  路  10Comments