Pylint要求安裝astriod忧换,logilab-common盔憨,setuptools等包洗搂,可以分別到相應(yīng)的網(wǎng)址上去下載热康。
1.下載setuptools沛申, 網(wǎng)址:https://pypi.python.org/pypi/setuptools/1.1.6
2.下載pylint,目前推薦下載1.3.1版本姐军,網(wǎng)址:https://bitbucket.org/logilab/pylint
3.下載astriod铁材,網(wǎng)址:https://bitbucket.org/logilab/astroid
4.下載logilab-common,網(wǎng)址:http://www.logilab.org/projects/common
Pylint在Windows上的安裝
1.安裝Python的包(高于版本2.2)奕锌,右鍵單擊桌面上的我的電腦圖標著觉,選擇屬性,高級惊暴,環(huán)境變量饼丘,在$PATH中添加Python的安裝路徑,如C:\Python26\缴守。
2.使用解壓縮工具解壓縮所有的包葬毫。
3.打開命令行窗口镇辉,使用cd依次進入logilab-astng屡穗、logilab-common贴捡、astriod和Pylint解開的文件夾中,運行命令python setup.py install來安裝村砂。
4.安裝完成后烂斋,在Python的安裝路徑下出現(xiàn)一個Scripts文件夾,里面包含一些bat腳本础废,如pylint.bat等汛骂。
5.為了使調(diào)用pylint.bat的時候不需要輸入完整路徑,在Python的安裝目錄下創(chuàng)建pylint.bat的重定向文件评腺,這是一個純文本文件pylint.bat帘瞭,里面包含pylint.bat的實際路徑,如:C:\Python26\Scripts\pylint.bat蒿讥。(在環(huán)境變量中配置pylint.Bat的路徑)
6.安裝完成后蝶念,可以通過pylint [options] module_or_package來調(diào)用Pylint了。(未研究明白)
PyCharm界面選擇File -> Settings -> Tools -> External Tools芋绸,點擊“+”媒殉,設(shè)置的參數(shù)如下圖所示:
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"廷蓉,點擊執(zhí)行即可
錯誤及解決辦法:
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
解決辦法:執(zhí)行easy_install mccabe添加mccabe模塊
5.-rn does not exist
解決辦法:未解決-----發(fā)現(xiàn)pycharm自帶的啦B黻肌L胰!行楞!