I'm currently in the process of setting up my configuration for my Neovim environment and I'm struggling with some Python related issues.

I'm on macOS with nvim 0.9.4, installed over brew (if that should be relevant). I created a virtualevn with pyenv (the path to that env is /Users/name/.pyenv/versions/3.12.0/bin/). I'm using vim-plug as a plugin manager. My configuration looks like this

syntax on
filetype plugin indent on
set number
set tabstop=4
set expandtab
set softtabstop=4
set shiftwidth=4
set autoindent
set smartindent

call plug#begin('~/.local/share/nvim/plugged')
Plug 'jiangmiao/auto-pairs'

" Telescope
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-tree/nvim-web-devicons'
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.4' }

" Theme
Plug 'daltonmenezes/aura-theme', { 'rtp': 'packages/neovim' }

" Language server
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'}
Plug 'pappasam/coc-jedi', { 'do': 'yarn install --frozen-lockfile && yarn build', 'branch': 'main' }
Plug 'neoclide/coc-tabnine', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-yaml', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'}

" Python
Plug 'numirias/semshi', { 'do': ':UpdateRemotePlugins' }    " Syntax Highlighting
Plug 'averms/black-nvim', {'do': ':UpdateRemotePlugins'}    " Black formatter

" Debugging
Plug 'puremourning/vimspector'
call plug#end()
" Theme
colorscheme aura-dark-soft-text

let g:python3_host_prog = '/Users/name/.pyenv/versions/3.12.0/bin/python3'

" Find files using Telescope command-line sugar.
nnoremap <leader>ff <cmd>Telescope find_files<cr>
nnoremap <leader>fg <cmd>Telescope live_grep<cr>
nnoremap <leader>fb <cmd>Telescope buffers<cr>
nnoremap <leader>fh <cmd>Telescope help_tags<cr>

" use Ctrl+Space to trigger completion and navigate to the next complete item
inoremap <silent><expr> <c-space> coc#refresh()
" Use <Tab> and <S-Tab> to navigate the completion list:
inoremap <expr> <Tab> coc#pum#visible() ? coc#pum#next(1) : "\<Tab>"
inoremap <expr> <S-Tab> coc#pum#visible() ? coc#pum#prev(1) : "\<S-Tab>"

" Vimspector
" mnemonic 'di' = 'debug inspect' (pick your own, if you prefer!)
" for normal mode - the word under the cursor
nmap <Leader>di <Plug>VimspectorBalloonEval
" for visual mode, the visually selected text
xmap <Leader>di <Plug>VimspectorBalloonEval

runtime coc-init.vim

After installing semshi, I started seeing an error message when I open a Python file in nvim, i.e.

Error detected while processing BufNewFile Autocommands for "*":
Error executing lua callback: ...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:24: Error executing lua: ...brew/Cellar/neovim/0.9.4/share/n
vim/runtime/filetype.lua:25: BufNewFile Autocommands for "*"..FileType Autocommands for "*"..function <SNR>23_filetype_changed, line 4: Vim:E492: Not
an editor command:             Semshi enable
stack traceback:
        [C]: in function 'nvim_cmd'
        ...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:25: in function <...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:24>
        [C]: in function 'nvim_buf_call'
        ...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:24: in function <...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_buf_call'
        ...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:24: in function <...brew/Cellar/neovim/0.9.4/share/nvim/runtime/filetype.lua:10>

Running :checkhealth reveals

coc: health#coc#check

- OK nvim version satisfied
- OK Environment check passed
- WARNING pyx command not work, some extensions may fail to work, checkout ":help pythonx"
- WARNING Install pynvim by command: `pip install pynvim --upgrade`
- OK Javascript bundle build/index.js found
- OK Service started

and :checkhealth provider

provider: health#provider#check

Python 3 provider (optional) ~
- pyenv: Path: /opt/homebrew/Cellar/pyenv/2.3.31/libexec/pyenv
- pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
- pyenv: Root: /Users/name/.pyenv
- Using: g:python3_host_prog = "/Users/name/.pyenv/versions/3.12.0/bin/python3"
- Executable: /Users/name/.pyenv/versions/3.12.0/bin/python3
- Python version: 3.12.0
- pynvim version: 0.5.0dev0
- OK Latest pynvim is installed.

Python virtualenv ~

and last but not least :echo has('python3') returns 0.

So I first assumed that I was missing the pynvim package and that my Neovim had no built-in python... But

  • the pyenv environment has pynvim installed and up-to-date (I triple checked)
  • whenever I open a clean nvim session (i.e. empty, no files) and do :echo has('python3') I get 1.

If anybody sees something that would explain this, I would really appreciate the input. Thanks.


After @VivianDeSmet's answer, I updated my pynvim package in the virtual environment, but the issue still persists. :checkhealth no gives

Python 3 provider (optional) ~
- pyenv: Path: /opt/homebrew/Cellar/pyenv/2.3.31/libexec/pyenv
- pyenv: $PYENV_ROOT is not set. Infer from `pyenv root`.
- pyenv: Root: /Users/name/.pyenv
- Using: g:python3_host_prog = "/Users/name/.pyenv/versions/default/bin/python3"
- Executable: /Users/name/.pyenv/versions/default/bin/python3
- Python version: 3.12.0
- pynvim version: 0.5.0dev0
- OK Latest pynvim is installed.

Python virtualenv ~
- $VIRTUAL_ENV is set to: /Users/iilak/.pyenv/versions/default
- Python version: 3.12.0
- OK $VIRTUAL_ENV provides :!python.

Eror message when opening a Python file stays the same and behaviour as well (i.e. opening non-python files and running :echo has('python3') returns 1, but for Python files 0)

1 Answer 1


The current released version of pynvim doesn't support Python 3.12 see this issue.

You can solve that problem by installing the trunk version of pynvim to solve the problem:

pip install 'pynvim @ git+https://github.com/neovim/pynvim'

Remark: Neovim potentially uses two installations (determined by the pair: (sys.version, sys.path)) of Python:

  1. The one that is embedded (the one used by the :py3 command), that you can determine by running the commands: :py3 print(sys.version) :py3 print(sys.path)
  2. The one that is determined by the value of the variable g:python3_host_prog

I suspect you need that both have pynvim installed or that at least the first has pynvim installed (you can verify that by running :py3 import pynvim).

  • 1
    Thanks for the answer! I updated my pynvim package to 0.5.0dev but the problem persists. I update my questions with the new :checkhealth, status, but bscly. everything seems okey to me. Any ideas?
    – Sito
    Nov 10, 2023 at 10:37
  • 1
    It seems the Python embedding is not working yet. What is the result of :py3 print(sys.version)? Nov 10, 2023 at 12:19
  • 1
    Maybe this answer could help you figuring out what is not working. Nov 10, 2023 at 12:20
  • 1
    Regarding the answer you linked to: 64 bit version, Python3 support should work since the above :py3 command is executed and shows the correct output... The issue really only appear when opening a Python File... Really weird
    – Sito
    Nov 10, 2023 at 22:16
  • 1
    :py3 import pynvim; print(pynvim.__file__) -> /Users/name/.pyenv/versions/3.12.0/lib/python3.12/site-packages/pynvim/__init_ _.py and the path gives ['/Users/name/.pyenv/versions/3.12.0/lib/python312.zip', '/Users/name/.pyen v/versions/3.12.0/lib/python3.12', '/Users/name/.pyenv/versions/3.12.0/lib/p ython3.12/lib-dynload', '/Users/name/.pyenv/versions/default/lib/python3.12/ site-packages', '_vim_path_']
    – Sito
    Nov 11, 2023 at 14:32

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.