PDA

View Full Version : Geany and Python 3.0?



babanner
January 13th, 2009, 09:32 PM
Could you please tell me how to configure Geany to execute my python scripts with Python 3.0, rather than with the default Python 2.5.2 ? It seems i should change something in Preferences->Terminal, but i don't know what.
Thanks in advance.

NoBugs!
January 14th, 2009, 04:07 AM
I don't know exactly, but I think it has to do with how the templates are set up. Templates for geany IDE are in home directory/.geany/templates folder.

garyczek
January 14th, 2009, 11:35 AM
Hi, in /usr/local/share/geany/filetypes.python are saved build settings in part [build_settings]. There you can change what command will be executed.
Firstly read ~/.config/geany/filedefs/filetypes.README (OR maybe ~/.geany/filedefs/filetypes.README). Sou you should copy filetypes.python to geany's config. And then make some changes in it.
I recommend you to copy filetype_extensions.conf, filetypes.python to filetypes.python2 and to filetypes.python3 if the version could be determined by the file extension. And then set all values as needed.

Another solution:
Did you tried Edit -> Preferences -> Tools and in the Make line (or whatever) put '/usr/bin/python3 "%f" #' (I'm not sure about the path to python 3.0 binary) (do not forget # at the end)? And then to execute script press F8 (for Make line). It's not the prettiest way, but I think it will do what you want.

MockY
January 14th, 2009, 11:21 PM
I don't have the /usr/local/share/geany/ directory.
And putting /usr/bin/python3.0 "%f" # in the make field did not change anything.

MockY
January 15th, 2009, 11:26 PM
This worked for me:

replace the last 2 lines in /usr/share/geany/filetypes.python (it is NOT located in the /local folder) with this:

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

C0pac3t1c
January 20th, 2009, 07:57 PM
Thanks everyone. I was looking for a way to do this...

mityay
January 28th, 2009, 03:46 PM
After I installed python 3.0, how can I remove python 2.5 without removing all the dependencies? Thanks

MockY
February 4th, 2009, 09:02 PM
I don't suggest that you do since a huge amount of packages are written (as far as I understand) in python 2.* and you would most likely bork your install. I would wait until Ubuntu supports it out of the box.

mahela007
February 26th, 2009, 10:37 AM
This worked for me:

replace the last 2 lines in /usr/share/geany/filetypes.python (it is NOT located in the /local folder) with this:

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

I'm havin the same problem
However I can't modify the file because it when I modify it and try to save it I get a message saying it isn't possible to save the file. I use kubuntu

cyfur01
February 26th, 2009, 10:41 AM
However I can't modify the file because it when I modify it and try to save it I get a message saying it isn't possible to save the file.
Since this is in the /usr folder, you'll have to be root when editing the file. Thus, I recommend you use konsole to run "sudo kate /usr/share/geany/filetypes.python" (or replace kate with your preferred text editor).

mahela007
February 26th, 2009, 12:37 PM
but now I get this ugly red error (after I have saved the file and attempted to run another program in geany) in the command line window

Warning: Could not start program './geany_run_script.sh' with arguments './geany_run_script.sh'.

cyfur01
February 26th, 2009, 07:26 PM
What version of Geany are you running?

The script should be created in the same directory as the python script you are trying to run. Can you verify that there is a geany_run_script.sh there? What are the ownership/permissions of the script? If all else fails, you should be able to delete the script, and have Geany auto-generate it the next time you try to run the script (providing of course that you have write access to the directory).

There was some talk of adding an option to bypass this script here (https://lists.uvena.de/pipermail/geany/2007-December/002379.html), which appears to be present in Geany 0.14 (Edit->Preferences->Terminal, Check "Execute Programs in VTE" and "Don't Use Run Script"). This will launch it in the terminal embedded in the geany window.