Skip to content

Detection of flake8 is inconsitent/broken in some cases #1892

Closed

Description

@rsyring

Environment data

  • VS Code version: 1.23.1
  • Extension version (available under the Extensions sidebar): 2018.5.0
  • OS and version: Ubuntu 16.04 (w/ latest updates)
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.5
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): pipenv/virtualenv
  • Relevant/affected Python packages and their versions:
    • pipenv, version 11.10.0

Actual behavior

"Linter Flake8 is not installed." notification box pops up every time I try to save a Python file.

Expected behavior

Flake8 linting works for python file

Steps to reproduce:

  1. pipenv --python 3.6 shell
  2. code .
  3. pipenv install flake8 --dev
  4. Open Python file in VS code, edit, save.

But, in the VS Code "Terminal" tab, I can do:

(tarsnap-prune-0dGG-SaN)rsyring@loftey:~/projects/tarsnap-prune$ pip freeze
flake8==3.5.0
mccabe==0.6.1
pycodestyle==2.3.1
pyflakes==1.6.0
sh==1.12.14
(tarsnap-prune-0dGG-SaN)rsyring@loftey:~/projects/tarsnap-prune$ python
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import flake8
>>>
(tarsnap-prune-0dGG-SaN)rsyring@loftey:~/projects/tarsnap-prune$

I have other projects where flake8 linting works fine in vscode.

Logs

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

Starting the classic analysis engine.

Linter 'flake8' is not installed. Please install it or select another linter".
Error: Module 'flake8' not installed.

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

log.ts:159  INFO no standard startup: not using cached data
TMSyntax.ts:44 Overwriting grammar scope name to file mapping for scope source.jinja.
Old grammar file: /data/rsyring/.vscode/extensions/korekontrol.saltstack-0.0.5/syntaxes/jinja.json.
New grammar file: /data/rsyring/.vscode/extensions/wholroyd.jinja-0.0.8/syntaxes/jinja.json
e.register @ TMSyntax.ts:44
TMSyntax.ts:44 Overwriting grammar scope name to file mapping for scope text.yaml.jinja.
Old grammar file: /data/rsyring/.vscode/extensions/korekontrol.saltstack-0.0.5/syntaxes/sls.json.
New grammar file: /data/rsyring/.vscode/extensions/wholroyd.jinja-0.0.8/syntaxes/jinja-yaml.json
e.register @ TMSyntax.ts:44
webviewElement.ts:132 [Embedded Page] Blocked script execution in 'data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%0D%0A%3Chtml%20lang%3D%22en%22%20style%3D%22width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3Chead%3E%0D%0A%09%3Ctitle%3EVirtual%20Document%3C%2Ftitle%3E%0D%0A%3C%2Fhead%3E%0D%0A%3Cbody%20style%3D%22margin%3A%200%3B%20overflow%3A%20hidden%3B%20width%3A%20100%25%3B%20height%3A%20100%25%22%3E%0D%0A%3C%2Fbody%3E%0D%0A%3C%2Fhtml%3E' because the document's frame is sandboxed and the 'allow-scripts' permission is not set.
console.ts:136 [Extension Host] vscode-icons is active!
console.ts:136 [Extension Host] Python Extension: Linter 'flake8' is not installed. Please install it or select another linter". Error: Module 'flake8' not installed.
	at PythonExecutionService.<anonymous> (/data/rsyring/.vscode/extensions/ms-python.python-2018.5.0/out/client/common/process/pythonProcess.js:96:27)
	at Generator.next (<anonymous>)
	at fulfilled (/data/rsyring/.vscode/extensions/ms-python.python-2018.5.0/out/client/common/process/pythonProcess.js:12:58)
	at <anonymous>
t.log @ console.ts:136
notificationsAlerts.ts:42 Linter flake8 is not installed.
e.onDidNotificationChange @ notificationsAlerts.ts:42

Activity

  1. changed the title [-]Detection of flake8 extension is inconsitent/broken in some cases[/-] [+]Detection of flake8 is inconsitent/broken in some cases[/+] on Jun 7, 2018
  2. DonJayamanne commented on Jun 7, 2018

    @DonJayamanne

    Rather than activating python in the Shell and then opening vscode, please configure the path to the python executable in settings.json in the python.pythonPath setting.

    See here https://code.visualstudio.com/docs/python/environments#_how-to-choose-an-environment

  3. rsyring commented on Jun 7, 2018

    @rsyring
    Author

    Don Jayamanne (@DonJayamanne) While I like my method better, and hope it's supported, I tried what you suggested and it made no difference with the issue I reported.

  4. DonJayamanne commented on Jun 7, 2018

    @DonJayamanne

    Please could you provide the contents of your settings.json?

  5. rsyring commented on Jun 7, 2018

    @rsyring
    Author
    (tarsnap-prune-src-eTYfY8x1) rsyring@loftey:~/projects/tarsnap-prune-src$ cat .vscode/settings.json 
    {
        "python.pythonPath": "/data/tmp/virtualenvs/tarsnap-prune-src-eTYfY8x1/bin/python",
        "python.linting.flake8Enabled": false
    }
    (tarsnap-prune-src-eTYfY8x1) rsyring@loftey:~/projects/tarsnap-prune-src$ cat ~/.config/Code/User/settings.json 
    // Place your settings in this file to overwrite the default settings
    {
        "python.linting.enabled": true,
        "python.linting.pylintEnabled": false,
        "python.linting.flake8Enabled": true,
    
        // Configure glob patterns for excluding files and folders.
        "files.exclude": {
            // Defaults
            "**/.git": true,
            "**/.svn": true,
            "**/.hg": true,
            "**/.DS_Store": true,
    
            // Python related
            "**/.tox": true,
            "**/__pycache__": true,
            "**/*.pyc": true,
            "**/requirements/wheelhouse": true,
            "**/tags": true,
    
            // Other
            "**/.ci/**": true,
            "**/htmlcov": true
        },
        "editor.wrappingIndent": "none",
        "editor.renderIndentGuides": true,
        "files.insertFinalNewline": true,
        "files.trimTrailingWhitespace": true,
        "editor.rulers": [100]
        ,
        "window.zoomLevel": 1,
        "workbench.activityBar.visible": true,
        "editor.quickSuggestions": false,
        "editor.acceptSuggestionOnEnter": "smart",
        "editor.acceptSuggestionOnCommitCharacter": false,
        "editor.wordBasedSuggestions": true,
        "editor.wordWrapColumn": 100,
        "files.autoSave": "off",
        "vsicons.dontShowNewVersionMessage": true,
        "editor.minimap.enabled": false,
        "workbench.startupEditor": "newUntitledFile",
        "workbench.iconTheme": "vscode-icons",
        "[python]": {},
        "files.associations": {
            "**/ansible/group_vars/*": "yaml",
        },
        "symbolOutline.doSort": false,
        "symbolOutline.sortOrder": [
            "Class",
            "Function",
            "Module",
            "Constant",
            "Interface",
            "*",
            "Constructor",
            "Method"
        ],
        "docker.showExplorer": false,
        "symbolOutline.expandNodes": [
        ],
        "symbolOutline.doSelect": false,
        "editor.tabCompletion": true,
        "telemetry.enableTelemetry": false,
        "telemetry.enableCrashReporter": false,
        "cSpell.userWords": [
            "WSGI",
            "pipenv",
            "pytest",
            "repo"
        ]
    }
    

    Obviously, flake8 being disabled in the project's settings is because it's not working and the constant notice box is annoying.

  6. DonJayamanne commented on Jun 7, 2018

    @DonJayamanne
    • Please could you provide the output from the following command in your terminal:
      /data/tmp/virtualenvs/tarsnap-prune-src-eTYfY8x1/bin/python -m flake8 --version

    • Please confirm you have restarted VS Code after making the changes to the settings.json file.

  7. rsyring commented on Jun 7, 2018

    @rsyring
    Author

    Well, I had deleted and reinstalled the virtualenv so I had to re-install flake8. Once I did so, I have:

    $ /data/tmp/virtualenvs/tarsnap-prune-src-eTYfY8x1/bin/python -m flake8 --version
    3.5.0 (mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.6.0) CPython 3.6.5 on Linux
    

    And...amazingly?, I no longer have the problem with VS Code. I'm certain I tried that same workflow a couple times before I reported the issue and you can see in my terminal paste above that from inside VS Code, flake8 was installed. But...who knows, it's working now. Sorry to waste your time. :o/

  8. locked as resolved and limited conversation to collaborators on Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-lintingbugIssue identified by VS Code Team member as probable buginfo-neededIssue requires more information from poster

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions