请帮助:pylint 不适用于 Emacs23
我正在尝试在 Windows XP 上将 Pylint 与 Emacs 一起使用。我的 Emacs 版本是 EmacsW32 23.1,pylint 是 0.21.3,Python 2.5。在 easy_install pylint 之后,我将以下几行添加到 Emacs init 文件中,该文件是从 Emacs Wiki 复制的。
当我在.py文件上调用flymake模式时,我可以看到flymake开始语法检查,模式状态更改为flymake*,然后在几秒钟后返回到flymake。但没有报告错误,也没有语法错误突出显示。
我尝试在命令行中使用 pylint,它与命令“pylint test.py”一起使用,报告同一文件上的语法错误。
我什至尝试清除我的 .emacs 文件,但这没有帮助。
有人可以帮我解决这个问题吗?多谢。
(当(加载“flymake”t) (defun Flymake-pylint-init() (let* ((临时文件 (flymake-init-create-temp-buffer-copy 'flymake-创建-临时-就地)) (本地文件(文件相对名称 临时文件 (文件名-目录缓冲区-文件名)))) (列出“epylint”(列出本地文件)))) (添加到列表'flymake-allowed-file-name-masks '(“\\.py\\'”flymake-pylint-init)))
问题更新: 我在命令行提示符下尝试使用“pylint”和“epylint”进行以下操作。这是否意味着epylint有问题?
C:\Projects>pylint test_lib.py 未找到配置文件,使用默认配置 ************** 模块 test_lib E:13:语法无效 C:\Projects>epylint test_lib.py 'test_lib.py':1: [F] 没有名为 'test_lib.py' 的模块 C:\Projects>epylint 回溯(最近一次调用最后一次): 文件“C:\Python25\Scripts\epylint”,第 5 行,在
中 pkg_resources.run_script('pylint==0.21.3', 'epylint') 文件“C:\Python25\Lib\site-packages\pkg_resources.py”,第 489 行,在 run_script 中 self.require(需要)[0].run_script(script_name, ns) 文件“C:\Python25\Lib\site-packages\pkg_resources.py”,第 1207 行,在 run_script 中 execfile(脚本文件名,命名空间,命名空间) 文件“c:\python25\lib\site-packages\pylint-0.21.3-py2.5.egg\EGG-INFO\scripts\epylint”,第 3 行,在 中 epylint.Run() 文件“c:\python25\lib\site-packages\pylint-0.21.3-py2.5.egg\pylint\epylint.py”,第 93 行,在运行中 lint(sys.argv[1]) IndexError:列表索引超出范围
I am trying to use Pylint with Emacs on Windows XP. My Emacs version is EmacsW32 23.1, pylint is 0.21.3 with Python 2.5. After easy_install pylint, I added the following lines to Emacs init file, copied form Emacs Wiki.
When I invoke the flymake-mode on a .py file, I can see the flymake starting the syntax check, the mode status changed to flymake*, and then goes back to flymake after several seconds. But no error is reported, and no syntax error highlighting.
I tried to use pylint in command line, and it works with command "pylint test.py", reporting syntax errors on the same file.
I even tried to clear out my .emacs file, but it doesn't help.
Could someone help me on this? Thanks a lot.
(when (load "flymake" t) (defun flymake-pylint-init () (let* ((temp-file (flymake-init-create-temp-buffer-copy 'flymake-create-temp-inplace)) (local-file (file-relative-name temp-file (file-name-directory buffer-file-name)))) (list "epylint" (list local-file)))) (add-to-list 'flymake-allowed-file-name-masks '("\\.py\\'" flymake-pylint-init)))
Question Update:
I tried the following at command line prompt with "pylint" and "epylint". Does this mean epylint has a problem?
C:\Projects>pylint test_lib.py No config file found, using default configuration ************* Module test_lib E: 13: invalid syntax C:\Projects>epylint test_lib.py 'test_lib.py':1: [F] No module named 'test_lib.py' C:\Projects>epylint Traceback (most recent call last): File "C:\Python25\Scripts\epylint", line 5, in <module> pkg_resources.run_script('pylint==0.21.3', 'epylint') File "C:\Python25\Lib\site-packages\pkg_resources.py", line 489, in run_script self.require(requires)[0].run_script(script_name, ns) File "C:\Python25\Lib\site-packages\pkg_resources.py", line 1207, in run_script execfile(script_filename, namespace, namespace) File "c:\python25\lib\site-packages\pylint-0.21.3-py2.5.egg\EGG-INFO\scripts\epylint", line 3, in <module> epylint.Run() File "c:\python25\lib\site-packages\pylint-0.21.3-py2.5.egg\pylint\epylint.py", line 93, in Run lint(sys.argv[1]) IndexError: list index out of range
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Flymake调用的程序应该返回0错误级别,否则flymake认为调用子进程出现问题。
阅读 这个答案和那些补丁,我已经成功地使用 pylint 运行 Flymake :
在 Windows 上,但您可以在 Un*x 上执行相同的操作,我创建了一个批处理文件
pycheckers.bat
(可在您的 PATH 中访问) ) :在我的 .emacs 中,我放置了这些行:
现在,当我打开 .py 文件时,我执行 Mx
flymake-mode
来激活它。 Flymake 毫无问题地找到我的 python 错误和警告。请注意,您可以在 pycheckers.bat 文件中添加其他工具。
The program called by flymake should return 0 errorlevel or else flymake thinks there have been problems calling subprocesses.
Reading this answer and those patches, I have managed to run flymake with pylint :
On Windows, but you could do the same kind of thing on Un*x, I have created a batch file
pycheckers.bat
(accessible in your PATH) :In my .emacs, I have put those lines :
Now, when I open a .py file, I do a M-x
flymake-mode
to activate it. Flymake finds my python errors and warnings without problem.Note that you can add other tools in the
pycheckers.bat
file.我在 Linux 上使用 emacs22-nox,因此您可能需要搜索“font-lock-mode”来了解如何在您的计算机上执行此操作。首先按
Esc+x
进入 emacs 命令行。现在您可以输入 font-lock-mode 并按 Enter 键(命令行位于屏幕底部)。我在我的一台客户端服务器上遇到了同样的问题。他们的 emacs 默认情况下没有打开字体锁定模式。希望有帮助。I use emacs22-nox on linux so you may need to google "font-lock-mode" to figure out how to do it on your computer. First enter the emacs command line by pressing
Esc+x
. Now you can type font-lock-mode and hit enter (the command line is at the bottom of the screen). I had the same problem on one my clients servers. Their emacs didn't turn font-lock-mode on by default. Hope that helps.这是我的两分钱...
在 WinXP、linux、OS-X 上进行了测试。
Here are my two cents ...
tested on WinXP, linux, OS-X.