You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 20.04下.desktop运行Python输入程序时终端崩溃问题

服务器启动器终端崩溃问题

环境信息

  • Ubuntu版本:20.04
  • Python版本:3.10.6

问题描述

我制作了一个.desktop文件,用来便捷运行Python脚本启动游戏托管服务器,但在选择游戏后运行程序时终端会崩溃。

Python脚本代码

import os


sv = int(input("Run What Server?
1) Minecraft
2) Garry's Mod
"))
game = ""

try:
    if (sv == 1):
        game = "Minecraft"
    
    elif (sv == 2):
        game = "Garry's Mod"
    
except ValueError:
    print("invalid choice")
    exit(0)

print("Opening " + game + "...")

if (game == "Minecraft"):
    os.system("cd Servers/Minecraft && ./run.sh")
    
elif (game == "Garry's Mod"):
    os.system("cd Servers/Gmod && ./run.sh")

.desktop文件内容

#!/usr/bin/bash python3
[Desktop Entry]
Version=1.0
Name=Server Launcher
Type=Application
Exec=python3 /home/yomie/.local/share/applications/Servers.py
Terminal=true

已尝试的解决方法

  • 使用Builtins包
  • 完全重装Ubuntu
  • 更新与升级系统
  • 重新安装Python 3.10.6
  • 升级至Python 3.11
  • 修改/usr/bin/gnome-terminal使用不同Python版本

内容的提问来源于stack exchange,提问作者Yomie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 19:55:31