更新后调试中的PyDev编码错误 [英] PyDev encoding error in debug after update

查看:142
本文介绍了更新后调试中的PyDev编码错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近从Eclipse 4.2 / PyDev 2.7升级到Eclipse 4.4 / PyDev 3.8。不幸的是,当我们运行我们的代码作为Debug时,我们现在得到这个错误:


追溯(最近的最后一次呼叫):文件
C:\Programs\eclipse\plugins\org.python.pydev_3.8.0.201409251235\pysrc\pydevd.py,
line 2183,in
globals = debugger.run (setup ['file'],None,None)文件C:\Programs\eclipse\plugins\org.python.pydev_3.8.0.201409251235\pysrc\pydevd.py,
行1622,运行
pydev_imports.execfile(file,globals,locals)#执行脚本文件C:\Mercurial\ABC\tools\foo.pyc,行
1 SyntaxError :文件
中的非ASCII字符'\xf3'行1上的C:\Mercurial\ABC\tools\foo.pyc,但未声明
编码;请参阅 http://www.python.org/peps/pep-0263.html
详细信息


同样的代码作为一个普通的Python运行时运行正常,并且运行正常并在旧版本的Eclipse / PyDev上进行调试。



根据我在Stack Overflow和Online上发现的标准解决方案,当您收到此错误时,将#coding = utf-8添加到该文件有问题。但是,我们无法控制foo.pyc - 我们无法修改此文件。还有什么我们可以尝试吗?



python版本是2.7。

解决方案

从错误中可以看出,Python问题必须在顶部声明文件编码(由 http://www.python.org/peps/pep-0263.html



ie:通常只是

  #coding:utf-8 

在文件的顶部做窍门(使用你使用的实际编码)。



如果不是这样,你已经声明了编码请在PyDev跟踪器中输入问题: https://sw-brainwy.rhcloud.com/追踪器/ PyDev /


We recently upgraded to Eclipse 4.4 / PyDev 3.8 from Eclipse 4.2 / PyDev 2.7. Unfortunately, we now get this error when we run our code as Debug:

Traceback (most recent call last): File "C:\Programs\eclipse\plugins\org.python.pydev_3.8.0.201409251235\pysrc\pydevd.py", line 2183, in globals = debugger.run(setup['file'], None, None) File "C:\Programs\eclipse\plugins\org.python.pydev_3.8.0.201409251235\pysrc\pydevd.py", line 1622, in run pydev_imports.execfile(file, globals, locals) # execute the script File "C:\Mercurial\ABC\tools\foo.pyc", line 1 SyntaxError: Non-ASCII character '\xf3' in file C:\Mercurial\ABC\tools\foo.pyc on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

The same code works fine when run as a normal Python Run, and it worked fine in both Run and Debug on the older version of Eclipse/PyDev.

From what I've found on Stack Overflow and online, the standard solution when you get this error is to add "# coding = utf-8" to the top of the file in question. However, we don't have control of "foo.pyc" - there's no way for us to modify this file. Is there anything else we can try?

The python version is 2.7.

解决方案

From the error it seems a Python issue where you have to declare the file encoding at the top (as specified by http://www.python.org/peps/pep-0263.html)

i.e.: Usually just

#coding: utf-8

at the top of the file does the trick (using the actual encoding you use).

If that's not the case and you have the encoding declared, please enter an issue in the PyDev tracker: https://sw-brainwy.rhcloud.com/tracker/PyDev/

这篇关于更新后调试中的PyDev编码错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆