Pylint要求安装astriod,logilab-common,setuptools等包,可以分别到相应的网址上去下载。
1.下载setuptools, 网址:https://pypi.python.org/pypi/setuptools/1.1.6
2.下载pylint,目前推荐下载1.3.1版本,网址:https://bitbucket.org/logilab/pylint
3.下载astriod,网址:https://bitbucket.org/logilab/astroid
4.下载logilab-common,网址:http://www.logilab.org/projects/common
Pylint在Windows上的安装
1.安装Python的包(高于版本2.2),右键单击桌面上的我的电脑图标,选择属性,高级,环境变量,在$PATH中添加Python的安装路径,如C:\Python26\。
2.使用解压缩工具解压缩所有的包。
3.打开命令行窗口,使用cd依次进入logilab-astng、logilab-common、astriod和Pylint解开的文件夹中,运行命令python setup.py install来安装。
4.安装完成后,在Python的安装路径下出现一个Scripts文件夹,里面包含一些bat脚本,如pylint.bat等。
5.为了使调用pylint.bat的时候不需要输入完整路径,在Python的安装目录下创建pylint.bat的重定向文件,这是一个纯文本文件pylint.bat,里面包含pylint.bat的实际路径,如:C:\Python26\Scripts\pylint.bat。(在环境变量中配置pylint.Bat的路径)
6.安装完成后,可以通过pylint [options] module_or_package来调用Pylint了。(未研究明白)
PyCharm界面选择File -> Settings -> Tools -> External Tools,点击“+”,设置的参数如下图所示:
1.Tool settings
2.Program: C:\Python27\Scripts\pylint.exe
3.Parameters: -rn --msg-template="{abspath}:{line}: [{msg_id}({symbol}), {obj}] {msg}" $FilePath$
4.Working directory: $FileDir$
5.点击Output Filters,增加一个filter:$FILE_PATH$:$LINE$:
选择程序,右键快捷菜单中有"external
tool->Pylint",点击执行即可
错误及解决办法:
1.D:\Python27\Scripts\epylint.bat -rn"--msg-template={abspath}:{line}: [{msg_id}({symbol}), {obj}] {msg}"E:\python\apitest\apitest\apitest
Traceback(most recent call last):
File"D:\Python27\lib\site-packages\pylint-1.0.0-py2.7.egg\pylint\lint.py",line 30, in
from pylint.checkers import utils
File"D:\Python27\lib\site-packages\pylint-1.0.0-py2.7.egg\pylint\checkers\__init__.py",line 46, in
from astroid.utils import ASTWalker
ImportError: No module namedutils
解决办法:pip install utils(不行)
astroid换成别的版本的D:\Python27\Lib\site-packages\astroid-1.5.0-py2.7.egg
2.Traceback (most recent call last):
File"D:\Python27\lib\site-packages\pylint-1.0.0-py2.7.egg\pylint\lint.py",line 1065, in
Run(sys.argv[1:])
File"D:\Python27\lib\site-packages\pylint-1.0.0-py2.7.egg\pylint\lint.py",line 940, in __init__
linter.load_default_plugins()
File"D:\Python27\lib\site-packages\pylint-1.0.0-py2.7.egg\pylint\lint.py",line 328, in load_default_plugins
self._load_reporter()
File"D:\Python27\lib\site-packages\pylint-1.0.0-py2.7.egg\pylint\lint.py",line 358, in _load_reporter
module =load_module_from_name(get_module_part(qname))
File"d:\python27\lib\site-packages\logilab_common-1.4.0-py2.7.egg\logilab\common\modutils.py",line 382, in get_module_part
path=path, context_file=context_file)
File "d:\python27\lib\site-packages\logilab_common-1.4.0-py2.7.egg\logilab\common\modutils.py",line 327, in file_from_modpath
return _file_from_modpath(modpath, path,context)
File"d:\python27\lib\site-packages\logilab_common-1.4.0-py2.7.egg\logilab\common\modutils.py",line 604, in _file_from_modpath
mtype, mp_filename = _module_file(modpath,path)
File"d:\python27\lib\site-packages\logilab_common-1.4.0-py2.7.egg\logilab\common\modutils.py",line 694, in _module_file
return _search_zip(modpath, pic)[:2]
File"d:\python27\lib\site-packages\logilab_common-1.4.0-py2.7.egg\logilab\common\modutils.py",line 625, in _search_zip
raise ImportError('No module named %s' %'.'.join(modpath))
ImportError: No module namedtext
解决办法:更换成了最新的安装包,没有提示这个错误了
3.pkg_resources.DistributionNotFound: The 'mccabe' distributionwas not found and is required by pylint
解决办法:执行easy_install mccabe添加mccabe模块
5.-rn does not exist
解决办法:未解决-----发现pycharm自带的啦!!!!
网友评论