Python Subprocess call() File Not Found Error

Viewed 473

I wanted to create a Minecraft Launcher using Python today, but the game cannot be started. As I can see, the subprocess.call() line gives an error.

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

Is there an alternative that I can use instead of the subprocess.call() function?

1 Answers

Instead of double slashes, try setting the path as a raw string.

i.e.: minecraft_directory = r"C:\Users\Mert KAPLANDAR\AppData\Roaming\.minecraft"

Related