Linter pylint is not installed

前端 未结 15 1773
遥遥无期
遥遥无期 2020-12-12 12:56

I want to run python code in Microsoft Visual Studio Code but it gives an error:

\"Linter pylint is not installed\"

I installed:

相关标签:
15条回答
  • 2020-12-12 13:20

    If you're reading this in (or after) 2020 and still having issues with pylint in VS Code for Windows 10, here is a quick solution that worked for me:

    Make sure python is installed for Windows, and note the installation path

    From an elevated command prompt, go to the installation directory for python

    cd C:\Users\[username]\Programs\Python\Python[version]\
    

    Install pylint

    python -m pip install pylint
    

    Pylint is now installed in the 'Python\Python[version]\Scripts\' directory, note/copy the path for later.

    Open settings in VS Code: Ctrl + ','

    Type in python.defaultInterpreterPath in the search field, and paste in the path to the Windows installation path for python:

    (e.g. C:\Users\[username]\AppData\Local\Programs\Python\Python[version]\python.exe)

    Do the same for python.pythonPath, using the same path as above

    Lastly, search for python.linting.pylintpath and paste the path to pylint.exe

    Restart VS Code

    That got rid of the warnings for me, and successfully enabled pylinting.

    0 讨论(0)
  • 2020-12-12 13:22

    I would like to add my trials and my solution following rob3c's answer.

    PS: My solution only concern Windows user.

    The problem:

    I tried the following settings without success:

    // settings.json
    "python.linting.pylintPath": ${workspaceFolder}\\_tools\\python3\\Scripts\\pylint
    

    and

    "python.linting.pylintPath": ${workspaceFolder}\\_tools\\python3\\Scripts\\pylint.exe
    

    I always had the following error message:

    Linter 'pylint' is not installed. Please install it or select another linter".
    Error: spawn c:\WS\myproject\_tools\python3\Scripts\pylint ENOENT
    

    Even with a pylint file in my folder:

    dir c:\WS\myproject\_tools\python3\Scripts\
    ...
    05.07.2017  09:34 AM                52 pylint    # ! no pylint.exe !
    ... 
    

    As my toolchain is based on msys, the pylint installed is without pylint.exe.

    The content of _tools\python3\Scripts\pylint file:

    #!python
    from pylint import run_pylint
    run_pylint()
    

    The solution

    My workaround was to create a batch file .vscode\pylint.bat with the following contents:

    %PYTHON3_EXE% _prefix\python3\Scripts\pylint %*
    

    (%PYTHON3_EXE% is an environment variable to python3 C:\Python34\python.exe)

    and to configure .vscode\settings.json as follow:

    // settings.json
    "python.linting.pylintPath": "${workspaceFolder}\\.vscode\\pylint.bat",
    

    Result

    Log from OUTPUT --> Python:

    ##########Linting Output - pylint##########
    
    c:\WS\myproject>C:\Python34\python.exe _tools\python3\Scripts\pylint
    --rcfile c:\WS\framework\pylintrc 
    --msg-template='{line},{column},{category},{msg_id}:{msg}'
    --reports=n
    --output-format=text
    c:\WS\myproject\myScriptToLint.py 
    Using config file c:\WS\myproject\pylintrc
    
    ------------------------------------
    
    Your code has been rated at 10.00/10
    

    vscode uses the Pylint version from my toolchain!

    0 讨论(0)
  • 2020-12-12 13:23

    I had this issue this weekend. It seems to have happened because I opened my project in my venv, but also opened a second instance outside of the venv. I never closed either instance - I just shut my PC down and let windows do the work. When I went back and called up VSCode from within my venv, both the project, and the other non-venv window opened. That's when I started seeing this error.

    To fix it I had to remove the \.vscode folder from the workspace directory.

    0 讨论(0)
提交回复
热议问题