简体   繁体   中英

I cannot use pylint in VSC using pipenv & bash for windows 10

While proceeding Django Project Now, I'm having trouble with linter in VSC, pylint. First I'm using virtual environments with pipenv. and I'm using Visual Studio Code Version 1.19.1 with Windows 10. The trouble that I'm having is even though I installed pylint with pipenv and pip commands, VSC can't recognize it and Installation with Visual Studio Code can't work在此处输入图片说明 在此处输入图片说明

First I figured out that python path settings pointed global setting, not virtual envs. so I edit settings.json for VSC like following way.

{
    "python.pythonPath": "C:\\Users\\seungjinlee\\AppData\\Local\\lxss\\home\\seungjinlee\\.local\\share\\virtualenvs\\seungjingram-6b3oTnkI\\bin\\python",
}

from在此处输入图片说明 but It didn't work as well. 在此处输入图片说明 在此处输入图片说明

Is it problem with bash for windows? I guess bash shell create virtual enviorments for Ubuntu. but I'm using editor VSC with windows 10 so it can't find pylint for windows,.,.,, plz help me..!

I had the same problem on Mac OS. I solved it with the next sequence:

$ cd project_directory
$ pipenv install pylint
$ code .

So, the thing is to run VS Code from command line with activated virtual environment. I'm not sure if it helps for Windows, though.

For Windows a workaround may be to specify exact path to pylint in workspace settings:

"python.linting.pylintPath": "C:\\Users\\seungjinlee\\AppData\\Local\\lxss\\home\\seungji‌​nlee\\.local\\share\‌​\virtualenvs\\seungj‌​ingram-6b3oTnkI\\bin‌​\\pylint"

I had the same issue. What worked for me was:

  1. Making sure VS Code was using the correct virtual environment by running Python: Select Interpreter from the command palette ( Ctrl+Shift+P ) and choosing the correct option (it should detect your virtual environment and suggest it, but if not, try setting python.pythonPath as some as suggested, as well as python.venvFolders and/or python.venvPath . Also maybe try creating your virtual environment in the same folder as your project)
  2. Running Python: Select Linter from the command palette and choosing pylint.
  3. And then I still have to sometimes change a character and then save to make it start linting.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM