Python Minecraft Launcher LIB文件未发现错误

发布于 2025-01-18 19:44:19 字数 1208 浏览 1 评论 0原文

我想今天使用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:\Users\Mert KAPLANDAR\Desktop\launcher.py", line 10, in <module>
    subprocess.call(str(minecraft_command))
  File "C:\Users\Mert KAPLANDAR\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 349, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Users\Mert KAPLANDAR\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Mert KAPLANDAR\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Sistem belirtilen dosyayı bulamıyor

I wanted to create a Minecraft Launcher using Python today, but the game cannot be started.

My Code:

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)

Error:

Traceback (most recent call last):
  File "C:\Users\Mert KAPLANDAR\Desktop\launcher.py", line 10, in <module>
    subprocess.call(str(minecraft_command))
  File "C:\Users\Mert KAPLANDAR\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 349, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Users\Mert KAPLANDAR\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\Mert KAPLANDAR\AppData\Local\Programs\Python\Python39\lib\subprocess.py", line 1420, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] Sistem belirtilen dosyayı bulamıyor

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紙鸢 2025-01-25 19:44:19

@Mert Kaplander,我相信错误可能是因为您没有安装了Minecraft版本。您可以使用以下方法检查:

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}")

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

@Mert Kaplander, I would believe the error might be because you don't have that version of Minecraft installed. You can check with the following method:

minecraft_launcher_lib.utils.get_installed_versions(minecraft_dir)

example:

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}")

Other than that, your code is an exact copy from the documentation. So I don't see an other error.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文