Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Django is not available on the PYTHONPATH #298

Open
jvrn3 opened this issue Oct 27, 2020 · 1 comment
Open

Django is not available on the PYTHONPATH #298

jvrn3 opened this issue Oct 27, 2020 · 1 comment

Comments

@jvrn3
Copy link

jvrn3 commented Oct 27, 2020

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
Copy link
Author

jvrn3 commented Oct 27, 2020

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant