How can I run a Python script from Ubuntu Dash?

I've written (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 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, it still opens the file in an editor.

I tried creating a 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.

Also, I tried pressing Alt-F2 and it brings up something like Windows' Win-R, but when I enter python3 it doesn't bring up a terminal window to display any print() output.

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.

16.04 - Python script cannot run from .desktop launcher, This works for me : First, my desktop file [Desktop Entry] Version=1.0 Name=My Application Comment=My Application Comment� Step 12: It basically tells the terminal to run the python file. Step 13: In case if you want to check which version of Python are you using, you can write python –version. Step 14: Instead of using Python 2 version, if you use Python 3 version, you can readily execute it by writing ‘python3’.

Python Dash Tutorial – Linux Hint, Dash happens to run on port 8050 by default, so when you run your Dash application on Duration: 21:24 Posted: Nov 20, 2018 Dash is Python framework for building web applications. It built on top of Flask, Plotly.js, React and React Js. It enables you to build dashboards using pure Python. Dash is open source, and its apps run on the web browser. In this tutorial, we introduce the reader to Dash fundamentals and assume that they have prior experience with Plotly.

Regarding your last paragraph:

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.

You almost answer yourself. In Linux you also have a PATH environment variable. You can check it in a console typing:

$ echo $PATH

I have my path edited in my /home/xbello/.bashrc file to something like this:

export PATH=$HOME/bin:$PATH

Now I put my programs and scripts in /home/xbello/bin, chmod them to +x, and they are always available from a terminal or an Alt+F2. You don't need the extension if you add the shebang #!/bin/env python. The problem is that the output of a print("Hello world") executed from an Alt+F2 is gonna be lost. You need some code like this:

#!/bin/env python3
import os

os.system("notify-send 'Hello world'")

How to run a Python script in Linux, Running a Script � Open the terminal by searching for it in the dashboard or pressing Ctrl + Alt + T . � Navigate the terminal to the directory where the script is located� mod_wsgi is an Apache module that can be used for serving Python scripts over HTTP via Apache web server. You can easily deploy applications written with frameworks and tools like Django,, Werkzug,, TurboGears, and Flask using mod_wsgi.

Using the gnome-panel GUI is probably the easiest way:

  1. Install gnome-panel.

    $ sudo apt install gnome-panel
  2. Launch the item edit script. You'll need to put the .desktop file in either ~/.local/share/applications or in /usr/share/applications. Keep in mind that /usr/share will be accessible to all system users.

    $ gnome-desktop-item-edit --create-new ~/.local/share/applications/Tester.desktop

  1. Fill out the launcher details.

  1. Then you'll have access to the icon from the launcher and can move it to the desktop or where ever you need it.

  1. If you ever need to edit the application, you have 2 options:

    a. Run the item edit script again to reopen the GUI.

    $ gnome-desktop-item-edit ~/.local/share/applications/Tester.desktop

    b. Open up the Desktop file directly in something like vim.

Appendix B – Running Programs, Running your Python scripts in Ubuntu Linux from the Dash menu requires considerable setup. Let's say we have a /home/al/ script (your Python � Python is installed by default on all the latest Ubuntu releases and it also usually comes with the IDLE application. However, if you have a minimal installation of Ubuntu that lacks any IDLE UI application, you can install it by following this method: Open the Ubuntu command line, The Terminal, either through the system Dash or the Ctrl+Alt+T

General: how to run Python scripts "behind" Flask - Dash, Hello there, My webApp is deployed on a VPS running on Ubuntu, with Gunicorn and NGinx. The app runs in a venv, and it's monitored by� I will just add a smal precision, if you use #!/usr/bin/env python you can just type ./ to execute your script as Terminal will take account of your header and use python to launch the script. But before you have to change execution permission by doing chmod +x .

Ubuntu / Unity attach script to Launcher, desktop file you can summon a GUI to help assist in doing this. install gnome- panel $ sudo apt-get install --no-install-recommends gnome-panel. launch the� To run the python script in the terminal there is a concept of "Current working directory", which is what directory (folder) it is currently "in". You can use the following Python command: python The file needs to be in the current working directory. In Linux, you can change the current working directory with the command cd.

Starting a Python Program via Launcher, The program works fine when I run it from IDLE or when I open a In the launcher command field I typed the /home/thomasaaron/ and in� I have a python script that takes in a .txt file and outputs a .txt file. I want to create a bash file that I can click on from my desktop to execute the python script. So far I have: #!/bin/bash cd /Desktop; cd ./py-data; python ./; exit; This just opens up the python script.

  • I dont think you can launch python script from ubuntu dash like this. Correct me if I am wrong but the way you are trying to do it, Ubuntu dash will try to find default application to open *.py files which generally will be a text editor. You need to make something like hello_world.desktop which in turn should contain directive to execute Take a look at this which might help you
  • see
  • I am missing something here. If I start dash (/usr/bin/dash) in a terminal, and launch the script (in all the forms you mentioned), I get the correct results. Could you add more details (maybe a screenshot)?
  • I don't have /usr/bin/dash, but I do have a /bin/dash. However, when I run that I just get a new bash-like $ prompt. By "Ubuntu Dash" I mean the Start Menu-like user interface that appears when you press the Windows key:
  • I saved this as hello.desktop (I assume that's the file extension I should use) but it doesn't appear when I type "hello" into Dash. Doing chmod +x on hello.desktop doesn't help.
  • I made a couple edits that might help - specifically about forcing it to the foreground
  • one quick guess: ~/ does not work, but /home/ben/ does
  • Unfortunately, it's not the ~ issue. The hello.desktop file simply doesn't show up in Dash; it just says "No results." after I type "hello" or "hello.desktop".
  • Ah, I think the problem is that the window disappears as soon as the Python script finishes. You have to either add a input('Press any key to continue') at the end, or have the .desktop file run a shell script that runs bash afterwards to keep the window open. I'll modify this answer correctly and accept it so you get the bounty. Thanks!
  • Yes, but this is running them from a terminal window, not running them from Dash. Or in the case of Alt-F2, it runs the script without opening a terminal window to display the output. I'm looking for a one-step solution.
  • You can open a terminal with e.g. os.system("terminal -e 'echo Hello world; sleep 2'"), changing terminal for your preferred terminal (gnome-terminal, lxterminal, etc). The good part of this is that you have your command available from terminal, Alt+F2 and Dash.