How to run Pylint with PyCharm
I want to configure pylint as an external tool on my entire project directory for a python project that I'm working on. I've tried to use the repository as a module with __init__.py
and without, and its not working either way.
I'm having difficulty setting up pylint to run with PyCharm. I know that I should be running it as an external tool, however the settings confuse me.
The authoritative source on their documentation is broken, so I can't check that up either.
You can set up pylint
to work with PyCharm by following the next steps:
Install pylint
:
$ pip install pylint
Locate your pylint
installation folder:
$ which pylint # MacOS/Linux
/usr/local/bin/pylint # this is just a possible output check yours
$ where pylint # Windows
%LocalAppData%ProgramsPythonPython36-32Scriptspylint.exe # possible location
Open the PyCharm settings window with File -> Settings
, then navigate to Tools -> External Tools
in the sidebar. (Or search "external tools")
Setup an external tool by clicking on the + sign and filling the fields accordingly. In Program
use the path you got when running which pylint
, for the other values you can use the same of the image.
Run pylint
from Tools -> External Tools -> pylint
:
Look your output in the PyCharm terminal
For more details, refer to Pylinting with PyCharm.
Update:
If you want to use pylint
to check your whole project or a particular file or directory, you can right click on your project root, file or directory, then External Tools -> pylint
as shown below.
At first install pylint with pip:
pip install pylint
You have to open “Settings > Tools > External Tools” and press the “+” button at PyCharm.
Here are an example with good settings.
A colleague pointed me towards pylint-pycharm on GitHub. It's a wrapper around pylint with output formatted for PyCharm. Here's how I set it up:
git clone https://github.com/perses76/pylint-pycharm.git
cd pylint-pycharm
python setup.py build
This creates build/scripts-2.7/pylint-pycharm
Then, in PyCharm, create a new External Tool with these settings:
Program: path to your installation of pylint-pycharm
Arguments: --virtualenv=$PyInterpreterDirectory$/.. $FileName$
Working directory: $FileDir$
Output filters: $FILE_PATH$:$LINE$:$COLUMN$:.*
Now run it from Tools -> External Tools -> PyLintPyCharm. Each line of output will be hyperlinked to the relevant position in the source code.
链接地址: http://www.djcxy.com/p/30266.html下一篇: 如何用PyCharm运行Pylint