MCP 1.8.8执行decompile.sh时触发Python TypeError错误求助
问题
尝试创建MCP工作区,运行decompile.sh生成文件时触发Python错误,错误堆栈如下:
Traceback (most recent call last): File "runtime/decompile.py", line 58, in decompile commands = Commands(conffile, verify=True, no_patch=no_patch, workdir=workdir, json=json) File "/Users/louie/Desktop/louie/mcp918/runtime/commands.py", line 176, in __init__ normalStart = self.readconf(workdir, json) File "/Users/louie/Desktop/louie/mcp918/runtime/commands.py", line 565, in readconf self.mcLibraries = MinecraftDiscovery.getLibraries(mcDir, self.jsonFile, osKeyword) File "/Users/louie/Desktop/louie/mcp918/runtime/MinecraftDiscovery.py", line 157, in getLibraries libFilename = "%s-%s-%s.jar"%(libSubdir, libVersion, substitueString(library['natives'][osKeyword])) File "/Users/louie/Desktop/louie/mcp918/runtime/MinecraftDiscovery.py", line 185, in substitueString str = str.replace("${arch}", getArch()) TypeError: coercing to Unicode: need string or buffer, NoneType found louie@Louies-MBP mcp918 %
操作系统为Mac,已安装Python 3和Java 8,寻求解决方法。
解决方案
切换到Python 2.7运行脚本:MCP 918仅适配Python 2.7,Python 3的类型系统会导致此类错误。
- 通过Homebrew安装Python 2.7:
brew install python@2 - 终端中指定Python 2执行脚本:
python2 runtime/decompile.py,或修改decompile.sh内的Python调用路径为python2
- 通过Homebrew安装Python 2.7:
修改
MinecraftDiscovery.py修复空值与架构兼容问题(若坚持用Python 3):- 打开
/Users/louie/Desktop/louie/mcp918/runtime/MinecraftDiscovery.py,找到substitueString函数,添加空值判断:def substitueString(str): if str is None: return "" str = str.replace("${arch}", getArch()) return str - 找到
getArch()函数,修改为适配Mac架构的版本:def getArch(): import platform arch = platform.machine() return "arm64" if arch == "arm64" else "x86_64"
- 打开
检查Minecraft版本JSON的natives配置:确认你使用的Minecraft版本JSON文件中,
libraries条目里的natives.osx字段存在非空有效值,若缺失需补充对应native库的配置。
内容的提问来源于stack exchange,提问作者louis
相关产品推荐
相关产品推荐

