Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make Python3 the default Python in Geany

I've been trying to modify the default Python compiler/run command in Geany.

Some searching indicated that I would need to modify `/usr/share/geany/filetypes.python's last two lines as follows

#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.

like image 337
user3817250 Avatar asked Mar 17 '15 17:03

user3817250


People also ask

How do I use Python 3 in geany?

Configuring Geany to use Python 3 Open Geany, and open a Python Hello World program. If you don't have one on your system, write one and save it as hello.py, and run the program. This makes sure Geany is trying to run Python programs. When you have a running hello.py program, go to Build >> Set Build Commands.


2 Answers

Add '3' to the end of "python" on the Build->Set Build Commands menu, as mentioned above.

Under Python commands, you should see:

  1. Compile python -m py_compile "%...

Add '3' to the end of python here

  1. Compile python3 -m py_compile "%...

enter image description here

like image 156
suspicious_williams Avatar answered Oct 21 '22 04:10

suspicious_williams


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.

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.

like image 28
frlan Avatar answered Oct 21 '22 05:10

frlan