如何使Python3成为Geany中的默认Python

2024-09-27 07:30:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在尝试修改Geany中的默认Python编译器/运行命令。

一些搜索表明,我需要修改`/usr/share/geany/filetypes

#compiler=python -m py_compile "%f"
#run_cmd=python "%f"
compiler=python3 -c "import py_compile; py_compile.compile('%f')"
run_cmd=python3 "%f"

然而,在重新启动Geany之后,Build -> Set Build Commands仍然显示旧命令,并且试图运行py3脚本会导致错误。


Tags: runpyimport命令buildcmdshare编译器
2条回答

如上所述,在Build->Set Build Commands菜单的“python”末尾添加“3”。

在Python命令下,您应该看到:

  1. 编译python-m py_Compile“%。。。

在此处将“3”添加到python的末尾

  1. 编译python3-m py_Compile“%。。。

enter image description here

首先:不要更改这样的全局配置,因为这将更改所有系统用户的默认行为,并可能导致混乱。

文件/usr/share/geany/filetypes.python中的更改将在~/.config/geany/filedefs/filetypes.python在家庭中所做的更改中被覆盖。

当使用菜单Build->Set Build Commands时,它也会保存在那里。实际上,不需要手动更新文件,而是通过菜单。这也将有优势,改变将是可见的,而不重新启动Geany。

相关问题 更多 >

    热门问题