Visual Studio Code Pylint AutoFix Not Showing Up On Ubuntu 17.04 - python

I set up a python project in visual studio code and this is the debugging option I'm using in my launch.json:
{
"name": "External Terminal/Console",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "",
"console": "externalTerminal",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit"
]
}
I installed pylint and created a settings.json file which looks exactly like this:
{
"python.linting.pep8Enabled": true,
"python.linting.pep8Path": "/usr/bin/pep8",
"python.linting.pylintPath": "/usr/bin/pylint"
}
The pylint linter errors are being displayed but there is no lightbubble showing up which helps fixing linter errors automatically.
What is causing this and how can I enable the lightbubble which helps me to fix the linter errors e.g. Fix all autofixable errors.?

Yes, there is no lightbubble from Pylint.
If you need a linter with lightbubble, try SonarLint.

Related

Setting up Anaconda for VSC

I am trying to set up Python Anaconda for Visual Studio Code, I can set the interpreter to run as python however when I run it I get an error message saying: "The Python path in your debug configuration is invalid.", when I open the launch.json I get the following output:
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config.python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
I am not entirely sure what I should change here to make it work?
Any ideas are very welcome as I am not able to find anything on this on google
Edit: This is how my editor looks: https://imgur.com/a/xoFmxc6

Setting the Python path in Visual Studio Code for file 'launch.json'

I have been using Visual Studio Code for a few years and I find it a really good IDE. I program in Python more than any other language.
It really bothers me that I did not get around to using the IDE's debugger (even though it's a feature).
Error when pressing the debug play button:
Failed to launch the Python Process, please validate the path 'export PATH=$PATH:/Library/Frameworks/Python.framework/Versions/2.7/bin/python'
Checking my PYTHONPATH:
My launch.json file:
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "/workspace/h5-automation/",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
}
Any ideas / suggestions?
If you are on a *nix system, launch the terminal and type which python to get the Python path, copy it and paste it as the value of pythonPath in the launch.json file.

VS Code python debugger only works one time.

The debugger in VS Code in only working one time (either using debugging or start without debugging) and after that it won't start at all. I then have to restart VS Code and it works. I only have this issue since updating to v1.18.1.
{
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"env": {},
"envFile": "${workspaceRoot}/.env",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
I am seeing the same thing. Even with a completely fresh install. This is quite a show stopper, any pointers appreciated.
In the statusbar i can see python being running still and i have not managed to stop it besides restarting vsc.

How to set up Python in VS Code?

I'm new to python (and in coding in general). I'd like to ask some help to set up python on VS Code. I've tried to follow several guides but none of them were really helpful.
The following have been downloaded:
Python 3.6
VS Code
Python extensions
1) Install VS Code
2) Go to View > Command Palette
3) Type ext install and click on Install Extensions
4) Search for Python and install it
5) Reload VS
6) Start coding
This worked for me:
.vscode/settings.json:
{
"python.linting.pylintEnabled": false,
"python.pythonPath": "python.exe"
}
.vscode/tasks.json:
{
"version": "2.0.0"
}
.vscode/launch.json:
{
"version": "2.0.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": false,
"pythonPath": "${config:python.pythonPath}",
"program": "${file}",
"cwd": "${workspaceRoot}",
"console": "internalConsole",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
}
]
}
You can replace "program": "${file}", with "program": "${workspaceRoot}/main.py", to run your main file no matter which file you've selected but I found that that makes errors like syntax errors sometimes not display correctly if at all.
Breaking on exceptions
Press CTRL + SHIFT + D
In the BREAKPOINTS panel, click on Uncaught Exceptions
enter image description here

How to configure Visual Studio Code to debug Django app in a virtualenv?

I would like to have possibility to do a debugging of Django application in Visual Studio Code. I have a virtualenv, made a change in launch.json file that look like this:
{
"name": "Django",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "${workspaceRoot}/.venv/bin/python2.7",
"program": "${workspaceRoot}/mysite/manage.py",
"args": [
"runserver"
],
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"DjangoDebugging",
"RedirectOutput"
]
},
put several break points in the code and run it. Unfortunately, the execution is not stopped on the line with break points. I tried the same without virtualenv and everything worked perfectly.
Please, point out what I am doing wrong here.
For me, the following 2 changes worked
Add an absolute path for pythonPath
Use the "--noreload" option while starting the project
Here's the relevant part of my config
{
"name": "Django",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"pythonPath": "/Users/xyz/Documents/dev/my_project/my_project_env/bin/python",
"program": "${workspaceRoot}/manage.py",
"args": [
"runserver",
"0.0.0.0:8080",
"--noreload"
],
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput",
"DjangoDebugging"
]
},
1) Press CTRL + ,
2) Select Workspace Settings
3) Add the following line in the settings file opened.
"python.pythonPath": "path_to_your_env"
You're done!
This official tutorial worked in my case.
Just needed to open the "command palette" of VS Code and select my Python Interpreter to the virtual environment:
Full reference: https://code.visualstudio.com/docs/python/tutorial-django#_create-a-project-environment-for-the-django-tutorial

Categories