Pages

Wednesday, June 6, 2012

How to get geany to use python3 as its default


How to get Geany to use Python 3 by as the python version 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 # infront of them)

Step 3.)
Now copy paste the following two lines into the bottom of the doccument:
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 python script in Geany you will be able to run (f5)
and use it as python3 (Assuming that is what you code in)


Cheers!

18 comments:

  1. Beautifully written and helpful article!

    ReplyDelete
  2. Exactly what I was looking for. Thanks.

    ReplyDelete
  3. you can also copy /usr/share/geany/filetypes.python into your home directory
    ~/.config/geany/filedefs and edit it there. You only need the few settings you are changing, all others will be read from the system wide file.

    ReplyDelete
  4. Thank you! I was wondering why my old code of Python 3 did not work.

    ReplyDelete
  5. Works great, thank you! Too bad that Geany does not have a better 'preferences' section for changing these types of things. Is there any way to get Geany to run BOTH Python2 and Python3?

    ReplyDelete
  6. Great. Your instructions worked.

    ReplyDelete
  7. I'm afraid if you are running Geany under Ubuntu 16.04 you'll find the filetypes file has changed a bit. At the bottom you find the build menu, I modified mine to

    [build-menu]
    # %f will be replaced by the complete filename
    # %e will be replaced by the filename without extension
    # (use only one of it at one time)
    FT_00_LB=_Compile
    FT_00_CM=python3 -m py_compile "%f"
    FT_00_WD=
    FT_02_LB=_Lint
    FT_02_CM=pep8 --max-line-length=80 "%f"
    FT_02_WD=
    error_regex=(.+):([0-9]+):([0-9]+)
    EX_00_LB=_Execute
    EX_00_CM=python3 "%f"
    EX_00_WD=

    which is now working well for Python 3

    ReplyDelete