LINUX run python script on terminal

Asked

Viewed 1,301 times

0

I created a simple script in python then a launcher on the desktop to run this script on the terminal but it is not opening the terminal. When I click to open the launcher nothing happens.

hello.py (script)

#!/usr/bin/env python
print('Hello World!')

hello.desktop (launcher)

[Desktop Entry]
Name=Hello
Exec=/home/mint/pythonapp/hello.py
Comment=
Terminal=true
Icon=cinnamon-panel-launcher
Type=Application

I made the command to make it executable too but nothing has changed

sudo chmod +x /home/mint/pythonapp/hello.py

If I turn the remote /home/mint/pythonapp/hello.py direct on the terminal works.

Linux Mint 19.1

  • In addition to putting +x in the file . py, you need to put +x also in the desktop file; Moreover the program does nothing, so the terminal will close very fast and almost not even see. Put something time consuming in your program to allow time to see the terminal open

2 answers

0


The script is working and is opening the terminal. The problem is that it is very simple and short, so the terminal opens and closes very fast and you can’t even see.
Just To test you can do the following in the script:

import time

print "Hello"

time.sleep(5)

print "World"

This will pause the program execution in 5 seconds, long enough for you to see if it actually works or not.

-1

You’ll have to go to the terminal and put:

DISPLAY=:0 python3 'lugar do diretório'/arquivo.py

an example is:

DISPLAY=:0 python3 'Área de Trabalho'/arquivo.py

Browser other questions tagged

You are not signed in. Login or sign up in order to post.