如何使 Python3 成为 Geany 中的默认 Python
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29105941/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I make Python3 the default Python in Geany
提问by user3817250
I've been trying to modify the default Python compiler/run command in Geany.
我一直在尝试修改 Geany 中默认的 Python 编译器/运行命令。
Some searching indicated that I would need to modify `/usr/share/geany/filetypes.python's last two lines as follows
一些搜索表明我需要修改`/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"
After restarting Geany however, Build -> Set Build Commands
still shows the old commands and attemping to run a py3 script causes errors.
然而,在重新启动 Geany 后,Build -> Set Build Commands
仍然显示旧命令并且尝试运行 py3 脚本会导致错误。
采纳答案by frlan
First at all: Don't change the global configuration for something like this, as this will change default behaviour for all system users and might lead into confusion.
首先:不要更改此类的全局配置,因为这将更改所有系统用户的默认行为并可能导致混淆。
The changes inside file /usr/share/geany/filetypes.python
will be overwritten in changes done inside your home on ~/.config/geany/filedefs/filetypes.python
.
文件/usr/share/geany/filetypes.python
中的更改将被您家中所做的更改覆盖~/.config/geany/filedefs/filetypes.python
。
When using the menu Build->Set Build Commands
it will be saved also there. In fact, there is no need to update the file manually, but via the menu. This will also have the advantage, changes will be visible without restarting Geany.
使用菜单时,Build->Set Build Commands
它也会保存在那里。事实上,不需要手动更新文件,而是通过菜单。这也有好处,无需重新启动 Geany 即可看到更改。
回答by suspicious_williams
Add '3' to the end of "python" on the Build->Set Build Commands
menu, as mentioned above.
Build->Set Build Commands
如上所述,将“3”添加到菜单上“python”的末尾。
Under Python commands, you should see:
在Python commands 下,您应该看到:
- Compile python -m py_compile "%...
- 编译 python -m py_compile "%...
Add '3' to the end of pythonhere
在此处将 ' 3'添加到python的末尾
- Compile python3-m py_compile "%...
- 编译python 3-m py_compile "%...