如何在 Geany 中将 Python3 设置为默认值 Python
How do I make Python3 the default Python in Geany
我一直在尝试修改 Geany 中的默认 Python compiler/run 命令。
一些搜索表明我需要修改 `/usr/share/geany/filetypes.python 的最后两行如下
#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 脚本会导致错误。
首先:不要像这样更改全局配置,因为这会更改所有系统用户的默认行为并可能导致混淆。
文件 /usr/share/geany/filetypes.python
中的更改将被您在 ~/.config/geany/filedefs/filetypes.python
上在家中所做的更改覆盖。
使用菜单 Build->Set Build Commands
时,它也会保存在那里。事实上,不需要手动更新文件,而是通过菜单。这也有好处,无需重新启动 Geany 即可看到更改。
如上所述,在 Build->Set Build Commands
菜单的 "python" 末尾添加“3”。
在 Python 命令下 ,您应该看到:
- 编译 python -m py_compile "%...
在python的末尾添加'3'
- 编译python3 -m py_compile "%...
对于Linux:
转到 > 构建 > 设置构建命令
在 Python 命令中,将命令文本框编辑为:
python3 -m py_compile "%f"
在执行命令中,将命令编辑为:
python3 "%f"
以相同的方式您可以为 Python2 配置 Geany,只需删除“3”即可:
在 Python 命令中,将命令文本框编辑为:
python -m py_compile "%f"
在执行命令中,将命令编辑为:
python "%f"
您还可以针对特定的 python 版本进行配置,例如 Python3.7 只需替换 Set Build Commmands 中的版本号,例如:
命令中的 python3.7 -m py_compile "%f"
和执行中的 python3.7 "%f"
对于Windows:
转到 > 构建 > 设置构建命令
在 Python 命令中,将命令文本框编辑为:
python -m py_compile "%f"
在执行命令中将命令编辑为(如果您使用的是 python3.7 并且 python 安装在 C 盘中,否则浏览到 Python 的安装位置并将其替换为路径,如果路径变量未设置):
C:\Python37\python "%f"
如果您在路径变量中设置了 python,那么这将起作用:
python "%f"
我一直在尝试修改 Geany 中的默认 Python compiler/run 命令。
一些搜索表明我需要修改 `/usr/share/geany/filetypes.python 的最后两行如下
#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 脚本会导致错误。
首先:不要像这样更改全局配置,因为这会更改所有系统用户的默认行为并可能导致混淆。
文件 /usr/share/geany/filetypes.python
中的更改将被您在 ~/.config/geany/filedefs/filetypes.python
上在家中所做的更改覆盖。
使用菜单 Build->Set Build Commands
时,它也会保存在那里。事实上,不需要手动更新文件,而是通过菜单。这也有好处,无需重新启动 Geany 即可看到更改。
如上所述,在 Build->Set Build Commands
菜单的 "python" 末尾添加“3”。
在 Python 命令下 ,您应该看到:
- 编译 python -m py_compile "%...
在python的末尾添加'3'
- 编译python3 -m py_compile "%...
对于Linux:
转到 > 构建 > 设置构建命令
在 Python 命令中,将命令文本框编辑为:
python3 -m py_compile "%f"
在执行命令中,将命令编辑为:
python3 "%f"
以相同的方式您可以为 Python2 配置 Geany,只需删除“3”即可:
在 Python 命令中,将命令文本框编辑为:
python -m py_compile "%f"
在执行命令中,将命令编辑为:
python "%f"
您还可以针对特定的 python 版本进行配置,例如 Python3.7 只需替换 Set Build Commmands 中的版本号,例如:
命令中的 python3.7 -m py_compile "%f"
和执行中的 python3.7 "%f"
对于Windows:
转到 > 构建 > 设置构建命令
在 Python 命令中,将命令文本框编辑为:
python -m py_compile "%f"
在执行命令中将命令编辑为(如果您使用的是 python3.7 并且 python 安装在 C 盘中,否则浏览到 Python 的安装位置并将其替换为路径,如果路径变量未设置):
C:\Python37\python "%f"
如果您在路径变量中设置了 python,那么这将起作用:
python "%f"