0
def hmsbookings() :
    os.system('python hmsbookings.py')
    root.after(60000, hmsbookings)

I tried these both lines, but for some reasons, it's not working out. It shows error :

/System/.../MacOS/Python: can't open file 'hmsbookings.py': [Errno 2] No such file or directory.

1 Answers1

0

The execution path could be different where the file is located.
In your case, the execution is in /System/.../MacOS/Python however your file is somewhere else. This misbehavior could be resolved if you use the full path of the file.

Let me assume, that your file is located in your Desktop. Then this is the modified code that uses absolute path.

import os
def hmsbookings() :
    os.system('python os.path.expanduser("~/Desktop/hmsbookings.py")')
    root.after(60000, hmsbookings)

I'm not familiar with macOS, I based on this question. If you need more information about absolute path on mac see this question.

zerocukor287
  • 555
  • 2
  • 8
  • 23
  • 1
    thanks! Btw, I tried this method `def hmsbookings() : my_dir = os.path.dirname(sys.argv[0]) os.system('%s %s %s' % (sys.executable, os.path.join(my_dir, 'hmsbookings.py'), os.path.join(my_dir, 'Argument')))` It worked out for me. – Harsh Mehta Dec 09 '21 at 00:26