1

I just installed Ubuntu linux on my laptop and made sure to install python.

After installing Python, I type the command python3 --version and found that I got version 3.9.7, which is stored in the /usr/bin/ directory.

However, when I manually check the directory contents in /usr/bin I find that I also have a Python 3.10 directory, but paid little attention to this.

Instead of re-installing gvim, which is may usual go to vim distribution, I decided to install Neovim.

I just successfully install Conqueror of Command (CoC), but noticed that it linked to a Python 3.10.0 interpreter. I can only guess that it sees the Python 3.10 directory in /usr/bin/, but it should instead point to the /usr/bin/Python3 directory.

How can I manually set the interpreter in CoC?

2
  • Can you explain what you mean by "coc is linked to python 3.10"? If I'm not mistaken coc doesn't require python. Are you referring to coc-python? In this case have you checked this issue and the python.setInterpreter setting?
    – statox
    Commented Feb 15, 2022 at 14:12
  • Welcome to Vi and Vim!
    – D. Ben Knoble
    Commented Feb 15, 2022 at 15:11

2 Answers 2

2

I use the :CocConfig command to edit the coc-settings.json file and make sure the python.pythonPath is set correctly:

Here is a excerpt of my coc-settings.json file to set the interpreter to Python36 on the Windows platform.

{
    "python.pythonPath": "C:\\Python36_x64\\python.exe",
    "python.formatting.provider": "black",
    ...
}
1
  • Hmm, this does not seem to fix the issue. Now when I start NeoVim on a Pythoin file it asks me which interpreter I want to use and gives me a list of options. Any idea why it is behaving this way?
    – Jon
    Commented Feb 19, 2022 at 16:32
0

You use the following lines in your .vimrc or in your init.vim in case you use neovim.

let g:python_host_prog= '/usr/bin/python'
let g:python3_host_prog= '/usr/bin/python3'
1
  • Welcome to Vi and Vim! Some explanation around why this solves the problem would improve the answer (you can edit to add more details). Also, note that this becomes somewhat platform/programmer specific (not all pythons are in /usr/bin, and you may want to use a venv-installed python). Another option might be something like exepath('python') or exepath('python3')
    – D. Ben Knoble
    Commented May 13, 2022 at 14:31

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.