Search code examples
pythonminecraftpopen

How to run minecraft server from python?


I cant figure out how to start the server using a python command.

s = subprocess.Popen('"D:\MC SERVER 2k19\server.jar" -jar server.jar java', stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)

This code runs without error but doesn't start the server in cmd.

Thanks.


Solution

  • It's got to do with how you're passing your arguments.

    subprocess.Popen(['java', '-jar', 'server.jar'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True, cwd='D:\MC SERVER 2k19')