0

I know mac users cannot use os.startfile() but is there any alternative for mac users?

I am just trying to load a file within python but I would like to find a way to do so.

Error:

 Module 'os' has no 'startfile' member
dejanualex
  • 3,872
  • 6
  • 22
  • 37

2 Answers2

1

You can try os.system with open. For example:

os.system("open Untitled.pdf") 

This will open the file Untitled.pdf with the default PDF application ('Preview', in my case).

Roy2012
  • 11,755
  • 2
  • 22
  • 35
1

you should just be able to do:

import subprocess as sp
sp.call(['open', 'application_or_file_name'])
Derek Eden
  • 4,403
  • 3
  • 18
  • 31