8

I have installed coc.nvim and extension coc-python(:CocInstall coc-python)

When I opened file I refused of linting and then get error:

[coc.nvim] Jedi error: Traceback (most recent call last):                                                                                                                File "completion.py", line 694, in <module>
[coc.nvim] Jedi error: Traceback (most recent call last):                                                                                                      
[coc.nvim] Jedi error:     import jedi
ModuleNotFoundError: No module named 'jedi'

I tried to reinstall extension and plugin but It doesn't help.

yalef
  • 95
  • 1
  • 1
  • 6

7 Answers7

7

It's recommended to use https://github.com/fannheyward/coc-pyright if you're using Python 3, or use https://github.com/pappasam/coc-jedi if you're using Jedi.

fannheyward
  • 18,599
  • 12
  • 71
  • 109
4

Looks like you don't have the jedi package installed for your python interpreter. I would expect it to work after you run (in your command line)

pip3 install jedi

I have also just seen that I installed the pynvim package in my python environment as well but I don't remember whether you need this.

joemrt
  • 161
  • 5
2

When I started to edit .py file there were some notification but cause I was typing the notification was skipped and then it showed me [coc.nvim] Jedi error: import Jedi.

It turns out the notification asked me to select a python interpreter (I had two interpreters: one from anaconda and second from python.org). While I installed Jedi to 'python.org' interpreter, I didn't install Jedi to anaconda's python interpreter and hadn't selected which python interpreter to use.

So you should do either:

  1. Select a python interpreter when prompted.
  2. If there's no prompt then manually select python interpreter:

:CocCommand python.setInterpreter "C:\Users\username\AppData\Local\Programs\Python\PythonVersion\python.EXE"
or
:CocCommand python.setInterpreter "/usr/bin/python3"

And don't forget actually install Jedi: pip install jedi

1

YMMV but I got past that exact error by adding this to my :CocConfig "python.jediEnabled": false

iamnotsam
  • 9,470
  • 7
  • 33
  • 30
0

Maybe this is answer on the github:

https://github.com/neoclide/coc-python/issues/193

Nigredon
  • 81
  • 1
  • 3
0

To solve a similar problem I did the two following actions:

  1. Install the last version of jedi:

    pip install jedi --upgrade

  2. Set the Coc Python interpreter to the version of Python I use (and for which jedi is installed)

    In the C:\Users\myuser.vim\Coc-Settings.json make sure the following line is present

    "python.pythonPath" : "C:\\Python36_x64",

    Where "C:\Python36_x64" is the path of my Python interpreter

Remark: The Coc-Settings.json file is not in C:\Users\myuser\vimfiles (gVim) nor in C:\Users\myuser\AppData\Local\nvim (NeoVim) like the :CocConfig command would let you think it is.

Vivian De Smedt
  • 1,019
  • 2
  • 16
  • 26
0

One way to do this is by adding "python.pythonPath": "python3" to your coc-settings.json file.

If you are like me and uses lots of python virtual env or conda env then do the following:

  1. Disable Jedi
$ vim ~/.config/coc/extensions/node_modules/coc-python/package.json
"python.jediEnabled": false,
  1. Set following to you :CocConfig to solve the no interpreter issue.
"python", {
\   'jediEnabled': v:false,
\   'pythonPath': split(execute('!which python'), '\n')[-1]
\ }

Hope this helps ~

Dwijay Bane
  • 110
  • 6