10

I'm using Pylint under Windows, and it's not reading my pylint-config.rc file. Is there a way to set up a default .rc file for Python within windows so that I don't have to keep typing it into the command line? Thanks.

brentlance
  • 2,189
  • 1
  • 19
  • 25

3 Answers3

19

I don't have a windows box at hand to test, but the code uses os.path.expanduser('~') to find the current user's home directory, and looks for a file calle .pylintrc in that directory.

According to the python documentation, on Windows, expanduser uses HOME and USERPROFILE if set, otherwise a combination of HOMEPATH and HOMEDRIVE. So my advice is to check in a Python interactive session what the following script outputs:

import os
print os.path.expanduser('~')

and put the configuration file as .pylintrc in that folder.

Alternatively, if you want to use different configuration files on a per project basis, you should know that if there is a file called pylintrc (without a leading dot) in the current working directory, then Pylint will use this one. If there is a file called __init__.py in the current working directory, Pylint will look in the parent directory until there is no such file and then look for a pylintrc configuration file. This is done so that you can maintain a per project config file together with you source code, and lauch Pylint from any directory in your source tree.

gurney alex
  • 13,247
  • 4
  • 43
  • 57
  • Thank you! I primarily made this question to store some information that I'm tired of googling, but it's always good to learn something as well. – brentlance Nov 02 '12 at 14:14
8

Since creating a file beginning with a dot is not allowed from Windows file explorer, you can create a template using:

pylint --generate-rcfile > .pylintrc
user3573031
  • 91
  • 1
  • 1
3

There are two possible ways to do this. One way is to edit the file C:\Python\Scripts\pylint.bat changing the line

python "%~dpn0" %* 

to

python "%~dpn0" %* --rcfile="C:\path\to\pylint.rc" 

Another way is to go to add an environment variable. Do this by going to Start->Control Panel->System then going to the Advanced tab and clicking Environment Variables. Then click New and create a variable named PYLINTRC with the value of C:\path\to\pylint.rc.

brentlance
  • 2,189
  • 1
  • 19
  • 25