Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
How do I open a file from python? Not using the open() function and read or write, I mean simulate a user double clicking on the file. So if I open file1.jpg I want it to open using the default image program.
Thanks
os.system(dxg-open)
in linux you can use xdg-open like bellow:
from subprocess import call call(['xdg-open','filename'])
Add a comment
On windows, you get this behavior if you execute through the win32 shell. An easy way to do that is with the subprocess module:
import subprocess as subp subp.call('file1.jpg', shell=True)
Required, but never shown
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.
Explore related questions
See similar questions with these tags.
os.system(dxg-open)