1

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)!!!

1
  • If you add #!/usr/bin/env python to the top of your script, you'll be able to run it directly (assuming you make the file executable). See e.g. stackoverflow.com/q/6908143/3001761 Commented Feb 28, 2015 at 9:37

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.