Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execute not working #1019

Closed
veribaka opened this issue May 2, 2016 · 22 comments
Closed

Execute not working #1019

veribaka opened this issue May 2, 2016 · 22 comments

Comments

@veribaka
Copy link

veribaka commented May 2, 2016

I just installed geany, tried both 1.23 and 1.27. Saved a script as test.py, when I press execute, the 3 gears icon briefly changes to a red cross icon and then goes back to 3 gears. No output anywhere.

The version number of GTK+ is 2.24.23

Doing this in Ubuntu 64bit 14.04.

The script is a simple Hello World.

@elextr
Copy link
Member

elextr commented May 2, 2016

Can you run your script from the command line python test.py?

@veribaka
Copy link
Author

veribaka commented May 2, 2016 via email

@veribaka
Copy link
Author

veribaka commented May 2, 2016

user@user-desktop:$ geany -V
geany 1.27 ((gerado em 2016-03-13 com)GTK 2.24.23, GLib 2.40.2)
user@user-desktop:
$ python
python python2 python2.7 python3 python3.4 python3.4m python3m
user@user-desktop:$ python3 python/testes.py
Hello Python World!
user@user-desktop:
$ python python/testes.py
Hello Python World!

@elextr
Copy link
Member

elextr commented May 2, 2016

Ok, when you said "No output anywhere" does that include any error messages in Menu->Help->Debug Messages?

@veribaka
Copy link
Author

veribaka commented May 2, 2016

When I open geany there are some messages, but none that are generated when executing I'm afraid. Nevertheless, here's the content:

12:58:14: Geany INFO : Geany 1.27, pt_PT.UTF-8
12:58:14: Geany INFO : GTK 2.24.23, GLib 2.40.2
12:58:14: Geany INFO : System data dir: /usr/share/geany
12:58:14: Geany INFO : User config dir: /home/user/.config/geany
12:58:14: Geany INFO : System plugin path: /usr/lib/x86_64-linux-gnu/geany
12:58:14: Geany INFO : Added filetype Cython (61).
12:58:14: Geany INFO : Added filetype Graphviz (62).
12:58:14: Geany INFO : Added filetype CUDA (63).
12:58:14: Geany INFO : Added filetype Clojure (64).
12:58:14: Geany INFO : Added filetype Genie (65).
12:58:14: Geany INFO : Added filetype Scala (66).
12:58:14: Geany INFO : Added filetype JSON (67).
12:58:14: Geany INFO : /home/user/python/testes.py : Python (UTF-8)
12:58:14: Geany INFO : Loaded /usr/share/geany/python.tags (Python), 5964 symbol(s).

@elextr
Copy link
Member

elextr commented May 2, 2016

Ok, just in case there is something in your config that is strange, can you try it running geany from the command line geany -c /tmp/xxx and open and run your file without changing anything else (where /tmp/xxx is something that does NOT exist).

@veribaka
Copy link
Author

veribaka commented May 2, 2016

Still same results - however there was perhaps a clue in the terminal:

error: Additional unexpected arguments found: ['/tmp/geany_run_script_F364GY.sh']

The file geany_run_script_F364GY.sh reads:

#!/bin/sh

rm $0

cd '/home/user/python'

python "testes.py"

echo "

------------------
(program exited with code: $?)"         


echo "Press return to continue"
#to be more compatible with shells like dash
dummy_var=""
read dummy_var

@elextr
Copy link
Member

elextr commented May 2, 2016

What is the Menu->Edit->Preferences->Tools->Terminal setting?

@veribaka
Copy link
Author

veribaka commented May 2, 2016

It's the default setting:

x-terminal-emulator -e "/bin/sh %c"

@elextr
Copy link
Member

elextr commented May 2, 2016

Looks like x-terminal-emulator doesn't like arguments, see here

Maybe try another terminal that is properly xterm compatible.

@b4n
Copy link
Member

b4n commented May 2, 2016

try changing it to xterm -e "/bin/sh %c". our default uses xterm, but some OS like Debian change it to x-terminal-emulator to try and use the user's preferred one. This is good in theory, but the wrapper is not good when it maps to some non-xterm-like terminals, including Konsole among others IIRC. It might be possible to use your preferred terminal anyway, but it might require using a slightly tuned command.

@elextr
Copy link
Member

elextr commented May 2, 2016

You might have to install xterm, I don't think Ubuntu includes it by default any more.

@veribaka
Copy link
Author

veribaka commented May 2, 2016

I tried changing to xterm -e "/bin/sh %c" and that worked flawlessly.

It's strange though - I have a different computer with exactly the same build. In that computer everything runs no problem. Didn't have to change to xterm. Neither of them seem to have x-terminal-emulator.

@b4n
Copy link
Member

b4n commented May 2, 2016

Try and see the output of $ update-alternatives --display x-terminal-emulator on both machines: it's likely they don't use the same wrapper to implement it.

@veribaka
Copy link
Author

veribaka commented May 2, 2016

You are correct. On the machine that "is working", the wrapper is gnome-terminal, on the one where it isn't working, it's terminator.

Can I fix this without uninstalling terminator?

@b4n
Copy link
Member

b4n commented May 2, 2016

Sure, using sudo update-alternatives --config x-terminal-emulator (interactive), or directly using sudo update-alternatives --set x-terminal-emulator /usr/bin/gnome-terminal.wrapper.

@elextr
Copy link
Member

elextr commented May 2, 2016

Although that will possibly make other things use gnome-terminal in preference to terminator, not just geany.

@b4n
Copy link
Member

b4n commented May 2, 2016

True; but if the wrapper doesn't really work as expected it's likely to also break other things. Also, it's generally possible to select the desktop's preferred terminal emulator separately, which can stay the same (with likely the same kind of issues if it's used for anything but simply spwaning the terminal itself)

@veribaka
Copy link
Author

veribaka commented May 2, 2016

Thanks, it is now working (almost) entirely as expected!

I am having a different problem now, related to the coding. I checked the document coding option, it is set to UTF8, which I believe is regular. However, when running this little script, I get the following message:


  File "listas.py", line 8
SyntaxError: Non-ASCII character '\xc3' in file listas.py on line 8, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Should I close this issue and open a new one?

Thanks for being so helpful!

@elextr
Copy link
Member

elextr commented May 2, 2016

Yes, open a new one, the terminal emulator thing is likely to reoccur, so we want this to refer to.

@b4n
Copy link
Member

b4n commented May 2, 2016

that's a Python question now :)
Python needs to know in which encoding the file it runs is, and this defaults to ASCII. UTF-8 is compatible with ASCII, but only for the characters that are part of ASCII -- obviously.
So, if you use any non-ASCII characters (i.e. accented letters), you'll have to tell Python your file is encoded in UTF-8. To do that, add

# -*- coding: utf-8 -*-

just below your shebang line (#!/...python), e.g. 2nd line probably.

Note that Python3's (current version of Python) default is UTF-8, so if you used it instead of Python2 it'd work without out of the box ;)

@b4n b4n closed this as completed May 2, 2016
@veribaka
Copy link
Author

veribaka commented May 2, 2016

Thanks, elextr and b4n!

Just a final remark regarding the coding issue. Amidst my confused troubleshooting, I changed the execute commands to python, rather than python3. Reverting this fixed it!

Thanks again 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants