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,175
  • 6
  • 21
  • 31

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
  • 10,697
  • 2
  • 19
  • 33
1

you should just be able to do:

import subprocess as sp
sp.call(['open', 'application_or_file_name'])
Derek Eden
  • 3,938
  • 1
  • 13
  • 29