0

我运行以下 python 脚本。

pygame2exe.py

ImportError: No module named japanese

怎么了?

你不知道解决方案吗?

4

2 回答 2

1

该脚本使用日语编码

# -*- coding: sjis -*-

[...]

args.append('japanese,encodings');

这是一个耻辱,因为它可以使用开箱即用的 UTF-8。

除非您安装了日语模块,否则您无法运行此脚本。我在网上找不到它的任何参考资料,我可以阅读代码:

# make standalone, needs at least pygame-1.5.3 and py2exe-0.3.1
# fixed for py2exe-0.6.x by RyoN3 at 03/15/2006

如果您还没有安装 pygame 和 py2exe 的最新版本,我会从它开始,因为它们可能嵌入了您需要的模块。

于 2009-08-20T10:17:29.640 回答
0

To add to e-satis' explanation, the "japanese" module is provided by the Japan PUG, but I don't think you've actually needed it since around Python 2.2. I believe that all the Japanese codecs are included in a standard Python install these days. I certainly don't use this module, and I handle SJIS in my programs just fine.

So I think you could just get rid if the forced import, and do fine. That is, delete these lines:

args.append('-p')
args.append('japanese,encodings') # JapaneseCodecを強制的に含める

Since you don't have the "japanese" module on your system, if the program runs OK on your system, then the frozen version should be OK without this module.

However, I would recommend using Unicode throughout instead of byte strings, and if you insist on byte strings, I'd at least put them in UTF-8.

于 2009-08-20T12:04:14.917 回答