简体   繁体   中英

how to run python application without use of terminal on ubuntu

I use Ubuntu.

Made a simple gui application in python using PyQt.

I can run this by using python interpreter as:

python application.py

I want to know whether is there any way to just run this application.py file by double-clicking on it as we do in windows(.exe files)!!!

You can just drag a file onto your desktop from your file manager to copy it (or link it) to the desktop. That should create an icon for the file on your desktop in most Linux distros.

To allow the system to run your script you need to ensure that the script starts with a proper shebang line, eg

#!/usr/bin/env python

and that the file has execute permissions. Your file manager will have some menu command to modify file permissions. Or you can just do it in the shell with

chmod a+x application.py .

If you've created a link to your script on the desktop you'll need to modify the permissions of the original file, not the link, since links don't have permissions themselves.

Then you can single -click the icon to launch it.

Create a .desktop file like this and put it in /usr/share/applications/

[Desktop Entry]
Type=Application
Name=XChat Firefox
Exec=/usr/bin/your_script
Icon=/usr/share/icons/xchats_icon

found here: https://askubuntu.com/questions/60667/apply-icons-to-bash-scripts/60670#60670

Check this link:

https://askubuntu.com/questions/761365/how-to-run-a-python-program-directly

You need to change how the file manager acts when you double click on executable files too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM