0

I've written hello.py (a basic "hello world" program) and would like to be able to quickly run it on my Ubuntu machine by pressing the Win key to open Dash, then type the name of the script (or something similar to that).

However, when I type hello.py into Dash, it opens the file in an editor rather than execute it. I added a shebang line #!/usr/bin/env python3 and run chmod u+x hello.py, it still opens the file in an editor.

I tried creating a hello.sh shell script that will run the Python script, but the shell script also gets opened in the editor when I type its name into Dash.

Is there a way to run a Python script by typing its name into Dash? Or is there another easy way to run an arbitrary Python script? Essentially, what I want is something like the Windows Run Dialog Box that appears when you press Win-R, which can run any program on the system PATH.

  • try python3 hello.py – Rinzwind Mar 16 '19 at 17:28
  • Simply typing "python3 hello.py" doesn't work. I believe it's not passing command line arguments to python3, and even if it was, there's no way Ubuntu would be able to find what directory hello.py is in. – Al Sweigart Mar 16 '19 at 17:31
  • sorry but then add the dir where the file is. – Rinzwind Mar 16 '19 at 17:32
  • Not sure Dash is the right tool for running programs. There is alt+f2 for that, but I am not sure it will display any output, in case this is what you want. – mikewhatever Mar 16 '19 at 17:41
  • it does if you use the correct coding for it (you need the graphical tool box and get an alert window with the text) – Rinzwind Mar 16 '19 at 17:43

0 Answers0