为什么以下项目失败?为什么它会成功使用"latin-1"编解码器?
o = "a test of \xe9 char" #I want this to remain a string as this is what I am receiving
v = o.decode("utf-8")
Run Code Online (Sandbox Code Playgroud)
结果是:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\encodings\utf_8.py",
line 16, in decode
return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError:
'utf8' codec can't decode byte 0xe9 in position 10: invalid continuation byte
Run Code Online (Sandbox Code Playgroud) 我现在无法弄清楚如何通过py2exe打包它:
我正在运行命令:
python setup2.py py2exe
Run Code Online (Sandbox Code Playgroud)
通过python 2.7.5和matplotlib 1.3.0和py2exe 0.6.9和0.6.10dev
这与matplotlib 1.2.x一起使用
我已经阅读了http://www.py2exe.org/index.cgi/ExeWithEggs并尝试实现处理mpl_toolkits的建议,因为它已成为命名空间包.
我也想在这里得到一个答案:http://matplotlib.1069221.n5.nabble.com/1-3-0-and-py2exe-regression-td41723.html
向__init__.py
mpl_toolkits 添加空白使其工作,但这只是解决问题的方法.
任何人都可以建议我需要使py2exe与matplotlib 1.3.0中的mpl_toolkits.axes_grid1一起工作吗?:
test_mpl.py是:
from mpl_toolkits.axes_grid1 import make_axes_locatable, axes_size
if __name__ == '__main__':
print make_axes_locatable, axes_size
Run Code Online (Sandbox Code Playgroud)
setup2.py是:
import py2exe
import distutils.sysconfig
from distutils.core import setup
# attempts to get it to work
import modulefinder
import matplotlib
import mpl_toolkits.axes_grid1
__import__('pkg_resources').declare_namespace("mpl_toolkits")
__import__('pkg_resources').declare_namespace("mpl_toolkits.axes_grid1")
modulefinder.AddPackagePath("mpl_toolkits", matplotlib.__path__[0])
modulefinder.AddPackagePath("mpl_toolkits.axes_grid1", mpl_toolkits.axes_grid1.__path__[0])
# end of attempts to get it to work
options={'py2exe': {'packages' : ['matplotlib', 'mpl_toolkits.axes_grid1', 'pylab', …
Run Code Online (Sandbox Code Playgroud)