Setting Python 3 as Geany's default python compiler

Started by makubex, November 09, 2012, 08:39:35 AM

Previous topic - Next topic

makubex

Another one from my personal list of tutorials(Original here!)

When I got my python books a few years ago it was all bleeding edge py3k and a while back before I got into android and java I was adamant of using python3 as my first and main language of choice for programming. As such in Linux I wanted to have an IDE that would run py3k as the default compiler for python scripts. After doing some more digging I learned that Geany could do this. So I'm going to show you how to get geany to run py3k as its python default.



Step 1. After installing geany you want to go into the terminal and enter this:

sudo <text editor here> /usr/share/geany/filetypes.python


Doing so will ask for your password and subsequently bring you to a text file for geany's python settings.

Step 2. Go to the bottom of the file and comment out the bottom two lines - Just add a # in front of them, this means if you want to go back the the 2.x compiler you can do so by following these instructions again.

Step 3. Now copy paste the following two lines into the bottom of the document:

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


Step 4. After you save it the next time you open your python3 script in Geany you will be able to run (f5) and use it as python3 (Assuming that is what you code in)

Job done!

Reversing these changes

To revert back to 2.x, all you do is go to that file again and un-comment the lines regarding 2.x and comment out the 3.x lines.