Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up coc.nvim for python

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.

like image 705
yalef Avatar asked Jun 03 '20 17:06

yalef


4 Answers

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.

like image 96
fannheyward Avatar answered Oct 26 '22 16:10

fannheyward


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.

like image 26
joemrt Avatar answered Oct 26 '22 16:10

joemrt


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

like image 2
Adilet Soronov Avatar answered Oct 26 '22 14:10

Adilet Soronov


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

like image 1
iamnotsam Avatar answered Oct 26 '22 15:10

iamnotsam