2

When I open a .py file on my Mac it opens in Xcode but wont run. Why does this happen and how do I fix this?

Xcode doesn't seem to recognize Python syntax. How do I fix this? (for example True and False are not recognized as keywords)

Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65
BoxTechy
  • 339
  • 2
  • 6
  • 16
  • 1
    @tehjoker Thanks! It did help. I knew that I should just change my default program, but it was just kinda weird that Xcode could open Python scripts without having a proper interpreter for it. – BoxTechy Jun 23 '16 at 23:18

1 Answers1

2

The default application for .py files on Mac is set to open in Xcode. Usually at installation time, you're provided with a list of checkboxes of extensions to associate with the program you're installing.

To fix this, follow this tutorial: http://www.imore.com/how-change-default-apps-os-x

Also, it doesn't recognize regular Python syntax because it's not configured to run Python. By default it's set to Objective C/Swift. You need to associate a project with a Python interpreter for it to pick up the syntax.

To setup a Python project in Xcode, follow this tutorial: https://stackoverflow.com/a/5438416/4889267

Community
  • 1
  • 1
Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65