微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Windows上的closurebuilder.py错误:“无法解码字节0x8f”

我正试图在Windows上运行closbuilder.py,无论我传递什么文件,我都会从Python获得同样的错误

python goog closure bin build closurebuilder.py –root = goog / closure / goog / –root = closurebuilder-example / –namespace =“myproject.start”

googclosurebinbuildclosurebuilder.py: Scanning paths... Traceback (most recent call last): File "googclosurebinbuildclosurebuilder.py",line 262,in <module> main() File "googclosurebinbuildclosurebuilder.py",line 200,in main sources.add(_PathSource(js_path)) File "googclosurebinbuildclosurebuilder.py",line 175,in __init__ super(_PathSource,self).__init__(source.GetFileContents(path)) File "C:UsersChrisCodePlaingoogclosurebinbuildsource.py",line 119,in GetFileContents return fileobj.read() File "C:Systempython33libencodingscp1252.py",line 23,in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 6857: character maps to <undefined>

这个错误抱怨UnicodeDecodeError与0x8f字节发生无论我试图build立一个简单的脚本,一个空白文件,或更复杂的东西。 我正在使用Visual Studio 2012来创build这些文件,我已经尝试使用认编码(Windows代码页1252)和UTF-8进行保存。

为了让事情变得简单,我正在尝试构build基本示例: https : //developers.google.com/closure/library/docs/closurebuilder

如果页面发生变化,则使用我正在使用的HTML和脚本:

HTML:

<!doctype html> <html> <head> <script src="../closure-library/closure/goog/base.js"></script> <script src="start.js"></script> </head> <body> <script> myproject.start(); </script> </body> </html>

JS:

goog.provide('myproject.start'); goog.require('goog.dom'); myproject.start = function() { var newDiv = goog.dom.createDom('h1',{'style': 'background-color:#EEE'},'Hello World!'); goog.dom.appendChild(document.body,newDiv); }; // Ensures the symbol will be visible after compiler renaming. goog.exportSymbol('myproject.start',myproject.start);

什么可能导致这个?

文档似乎没有提到Python的版本是必需的。 Python 3.x使用系统的认编码自动将文本文件解码为Unicode,这可能会导致您在Python 3.3中看到的错误

尝试Python 2.7。

降级到Python 2.7是我的解决方案的一部分,正如@ janne-karila所建议的。但是,在做出这个改变之后,我开始得到以下错误

WindowsError: [Error 2] The system cannot find the file specified

解决方案是将java.exe添加到PATH。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐