I've read a lot of conflicting SO posts, gone through all the relevant github issues I could find, and tried a myriad of config options in various sublime config files before finally giving up and resorting to this plea for help.
It's as the title states - I'd like to use sublime3 + sublime linter + something like pylint to lint my Python code using the Python installed in the specific project virtual environment. I'm not sure of the exact toolchain but as long as it works that's good enough for me.
Please, does anyone know if it's possible - and more importantly how to actually do it?
Thanks in advance,
You can quickly toggle a linter on or off. To do so: Bring up the Command Palette ( cmd+shift+p on Mac OS X, ctrl+shift+p on Linux/Windows) and type toggle , disable , or enable according to what you want to view all linters, only enabled linters, or only disabled linters.
Sublime Linter is the package of Sublime Text that helps you to perform linting in Sublime. It helps in creating files in different modes for the manipulation of code base. It is not an in built package and you need to install it manually.
Sublime Text 3 (ST3) is a lightweight, cross-platform code editor known for its speed, ease of use, and strong community support. It's an incredible editor right out of the box, but the real power comes from the ability to enhance its functionality using Package Control and creating custom settings.
There is an option to plug flake8
to SublimeLinter with custom virtualenv on per project basis in Sublime Text 3.
You should install flake8
to your virtualenv using pip install flake8
, but be careful no to include flake8
and its dependencies in your requirements.txt
.
Then you should edit your SublimeText project settings file and paste the SublimeLinter section there with full path to the Python binary for your particular project's virtualenv:
{
"settings": {
"SublimeLinter": {
"linters": {
"flake8": {
"python": "/path/to/virtualenv_folder/bin/python"
},
}
}
}
}
Or you may use the one shortened property SublimeLinter.linters.flake8.python
as it's been mentioned in the other answer.
So every time SublimeLinter executes in each *.py
file being opened from the project, flake8
will be executed from that custom Python virtualenv binary.
Update, now sublime linter recommends updating per project settings as follows:
"settings":
{
"SublimeLinter.linters.flake8.python": "/path/to/venv/bin/python"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With