Cannot select python executable for Xcode Project

Hello, all!


I am trying to use python in Xcode 7.3, el capitan. I created a new project and I defined /usr/local/bin/python as the build tool. Then I visited Product-->Scheme-->Edit Scheme, then on the run & info tab I want to change the executable to other. Then I visit the bin folder by pressing shift+command+g and pasting the path /usr/local/bin/python . Then I am able to see the python file but I can't select it. I can only select pip, brew and some other files....


Could anyone help?


Thank you very much.

MacBook Air, OS X El Capitan (10.11.5)

Posted on Jun 26, 2016 8:00 AM

Reply
2 replies

Jan 30, 2017 9:25 AM in response to ioannamac

When you use homebrew to install Python, it may leave the distribution in the Cellar, and not link the good stuff into the expected /usr/local path locations. If you cannot directly run python from /usr/local/bin/python, then this is likely what has happened, or Xcode doesn't like symlinked content 😕.


If you do not have an executable /usr/local/bin/python, and its library modules are not installed in the /usr/local/lib path, then you may want to do the following to remedy that, only if the preceding was true. See akauppi response in this stackoverflow article.

# the homebrew installed Python, not the System Python

brew link --overwrite python

which python

/usr/local/bin/python

By default, the environment variable PYTHONPATH is set, but empty, and will default to using the System Python library modules. In order to use your brew installed Python, the PYTHONPATH must be set to its /usr/local/lib/python.../lib path, where you are explicit with filling in the ellipsis with the real path components. At any rate, that path will end in /lib . I believe, and may be wrong, that even if you explicitly run /usr/local/bin/python, if the PYTHONPATH environment variable is left to default, that your version of python will attempt to use the System Python libraries.


This information may, or may not be helpful to your particular Xcode issue, as I do not use Python in Xcode.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Cannot select python executable for Xcode Project

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.