pylint doesn't point to virtualenv python

A cheap trick is to run (the global) pylint using the virtualenv python. You can do this using python $(which pylint) instead of just pylint. On zsh, you can also do python =pylint.


I am fairly sure that you need to install pylint under your virtual environment and then run that instance of it.

Update - Make life easier:

I would suggest that anybody working a lot in virtual environments create a batch file, (in a known location or on the path), or bash script with something like the following called something like getlint.bat:

pip install pylint

Invoking this after activating the virtual environment will install pylint into that virtual environment. If you are likely to be offline or have a poor internet connection you can, once when you have a good internet connection, (possibly once for each of python 2 & 3):

mkdir C:\Some\Directory\You\Will\Leave\Alone
pip download --dest=C:\Some\Directory\You\Will\Leave\Alone pylint

Which will download pylint and its dependencies to C:\Some\Directory\You\Will\Leave\Alone and you can modify getlint.bat to read:

pip install pylint --find-links=C:\Some\Directory\You\Will\Leave\Alone

It will then use the pre-downloaded versions.


Noufal Ibrahim's answer works if you execute pylint manually.

If you execute pylint from you editor/IDE, you need to configure the plugin correctly.

  • vim/syntastic
  • atom/linter-pylint
  • ...

It can get tricky. This may be considered a bug of each IDE/plugin, but that's how it is.

Modifying /usr/bin/pylint to write #!/usr/bin/env python as suggested in another answer fixes this for every use of pylint (manual use, or any editor integration).

However, at least in Debian, using #!/usr/bin/python is a design choice, not a bug. See here for the rationale.

To avoid modifying that system file, one can create a copy of /usr/bin/pylint in /usr/local/bin:

cp /usr/bin/pylint /usr/local/bin/pylint
vi usr/local/bin/pylint # Edit the file to use /usr/bin/env python

This won't be broken by a pylint update, but still infringes Debian's "strongly preferred choice".

This method requires root privileges. An unprivileged user may create an alias

alias pylint='/usr/bin/env python $(which pylint)'.

I always develop in virtualenv and I setup a postmkvirtualenv hook to install pylint and flake8 automatically when creating a virtualenv, so I don't use the versions ditributed by debian anymore.