neoclide / coc-python

Python extension for coc.nvim, fork of vscode-python
573 stars 51 forks source link

Django is not available on the PYTHONPATH #298

Open jvrn3 opened 3 years ago

jvrn3 commented 3 years ago

Hello, it's been a while I've been trying to use pyenv and coc-python but it does not work. I dont know much about pyenv, so I'd be very thankful if someone explains what is going wrong.

What I did

First I installed pyenv and created a virtualenv called neovim3 and installed all I need for coc-python.

pip install pylint
pip install pylint-django
pip install black
pip install jedi

After that, I set that location to neovim

let g:python3_host_prog = $HOME."/.pyenv/versions/neovim3/bin/python"

And my coc-setings.json

{
  "python.venvFolders":["envs", "venv", ".pyenv"],
  "python.jediEnabled": true,
  "python.jediPath":"/home/jvrn3/.pyenv/versions/neovim3/lib/python3.8/site-packages",
  "python.linting.enabled": true,
  "python.linting.pylintEnabled": true,

  "python.linting.pylintPath": "/home/jvrn3/.pyenv/versions/neovim3/bin/pylint",
  "python.linting.pylintArgs": [
    "--disable=C0111",
    "--load-plugins",
    "pylint_django"],
  "python.formatting.provider": "black",
  "python.formatting.blackPath": "/home/jvrn3/.pyenv/versions/neovim3/bin/black",
  "snippets.extends": {
    "javascriptreact": ["html", "javascript"]
  }
}

So I created a new django project with virtualenv at ~/coding/mysite/

When I open a python file, the linter shows error in every django import(eg: unable to import django.urls) and at the top of the file it shows "Django is not available on the PYTHONPATH"

What should I do for it to work well?

jvrn3 commented 3 years ago

I think I solved the problem by removing "python.linting.pylintPath". It'd be very nice if we create a little tutorial at the Wiki to avoid theses problems. What do you guys think? Maybe it seems obvious to experienced python developers, but for newcomers it's very hard to figure out this kind of problem.