pylint doesn't point to virtualenv python

后端 未结 10 1722
执笔经年
执笔经年 2021-01-07 19:19

I am pretty new to python and currenty I am trying to use pylint for checking code quality. I am getting a problem. My pylint doesn\'t point to virtualenv python interpreter

10条回答
  •  醉梦人生
    2021-01-07 19:45

    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.

提交回复
热议问题