9

I want to set up a python 3 project in Xcode, but I fail in the step where I'm asked to choose an executable for the scheme. See step 16 in the answer to Python in Xcode 4+?.

I use "which python3" to locate the executable:

$ which python3
/usr/local/bin/python3

but Xcode does not let me choose python3 from "/usr/local/bin" by clicking on it:

enter image description here

If I try following the suggestion of trojanfoe below to uncover the symbolic link through: ls -l /usr/local/bin/python3 I get to "../Cellar/python3/3.5.1/bin/python3" which in turn is a symbolic link pointing to "../Frameworks/Python.framework/Versions/3.5/bin/python3" which finally points at "Python3.5" in that directory. However, my Xcode also is not willing to let me select this file:

enter image description here

I'm running Xcode 7.3.1 in OS X 10.11.4. I've installed python 3.5.1 with home-brew.

Community
  • 1
  • 1
Noyer282
  • 934
  • 7
  • 18

4 Answers4

13

In the file selection window right-click on python3.5 and select quick look. Close the quick look window and python3.5 will become selectable. (images attached show workflow referencing the newer python3.6 - it is the same for all python releases).

Right click on python executable

Pop up window will be shown

Select quicklook

Python executable has been selectable and "choose" button is clickable

marken
  • 146
  • 2
  • 3
2

I just finished wrestling with this for about three hours. Okay, short answer (which marken, above, deserves credit for): Just right-click the dimmed out python3 executable, then click "Quick Look", then hit the space bar to exit the quick-look, and notice the executable is now selected, and just hit enter, or click "Choose". I have the following explanation to offer. The reason for our ability to see--but not to select--the python3 executable is that Homebrew uses a file alias, /usr/local/bin/python3, which brew's installation is given restricted permissions that Xcode is unable to pre-select, for reasons I am unsure of. (You might notice you can tediously select the executable at each and every runtime.) The alias points, in my case, to the Homebrew "Cellar"; for your reference, using the Terminal app to execute,ls -al /usr/local/bin/python3 reveals that my it's aliased to the true Homebrew python3 executable located at /usr/local/Cellar/python3/3.5.2_3/bin/(python3).

Levi Maes
  • 124
  • 2
0

Just right click and Quick Look option works. File becomes selectable, and then you can choose to specify it as an executable in your Xcode project.

Awais
  • 428
  • 5
  • 13
0

If you are using Anaconda, you can install the python.app package:

conda install python.app

Then, in Xcode, select </path/to/anaconda-environment>/python.app/Contents/MacOS/python.

(Note: Do not select the python.app in the bin directory (</path/to/anaconda-environment>/bin/python.app), which will result in some error regarding the Mach-O header.)

Stuart Berg
  • 17,026
  • 12
  • 67
  • 99