Python Minecraft Launcher Lib文件找不到错误



我今天想用Python创建一个Minecraft Launcher,但游戏无法启动。

我的代码:

import minecraft_launcher_lib
import subprocess
minecraft_directory = "C:\Users\Mert KAPLANDAR\AppData\Roaming\.minecraft"
options = minecraft_launcher_lib.utils.generate_test_options()
minecraft_command = minecraft_launcher_lib.command.get_minecraft_command("1.8.9", minecraft_directory, options)
subprocess.call(minecraft_command)

错误:

Traceback (most recent call last):
File "C:UsersMert KAPLANDARDesktoplauncher.py", line 10, in <module>
subprocess.call(str(minecraft_command))
File "C:UsersMert KAPLANDARAppDataLocalProgramsPythonPython39libsubprocess.py", line 349, in call
with Popen(*popenargs, **kwargs) as p:
File "C:UsersMert KAPLANDARAppDataLocalProgramsPythonPython39libsubprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "C:UsersMert KAPLANDARAppDataLocalProgramsPythonPython39libsubprocess.py", line 1420, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Sistem belirtilen dosyayı bulamıyor

@Mert Kaplander,我相信这个错误可能是因为你没有安装那个版本的《我的世界》。您可以使用以下方法进行检查:

minecraft_launcher_lib.utils.get_installed_versions(minecraft_dir)

示例:

import subprocess
import minecraft_launcher_lib
from colorama import Fore, init
for version in minecraft_launcher_lib.utils.get_installed_versions(minecraft_dir):
print(Fore.GREEN+ f"{version}")

除此之外,您的代码是文档的精确副本。所以我没有看到其他错误。

相关内容