Xcode: Cannot select python3 as executable

HI All, when I do the following I cannot select the python version as my executable.


Open Xcode

File > New Project > Other > External Build System

  

Specify path for the build tool which is the system path of python.

In my case


which python3
/Library/Frameworks/Python.framework/Versions/3.11/bin/python3


Product > Scheme > Edit Scheme

 

Run side tab > Info tab > Executable > Other > select the path above


--The first time I was able to select python3 but now I cannot - it is greyed out.




Any reason for this behaviour?


Thanks

MacBook Air (M2, 2022)

Posted on Dec 27, 2023 2:35 AM

Reply

Similar questions

4 replies

Dec 28, 2023 3:23 AM in response to bojack_horseman

bojack_horseman wrote:

Thank you both for your input. I normally develop my little Python scripts in Spyder or VS Code, and both are usable, but neither are amazing to be honest, plus VSCode is about to die on Mac.

So I was curious to see what Xcode had to offer. Not so much it seems for Python people! This is a shame, as I'd love to learn more about Xcode.

Regarding PATH, I can call python3 at any time from anywhere in Terminal, so I believe that must be set up properly. Also, by supplying the path to Xcode in the scheme, Xcode has the info it needs, but as I said, on second attempt the python3 file was greyed out. I wish it would let me select it and then produce an error - then I'd at least have a clue.

Without altering my original PATH statement, I also can run python3 from the command line and it will be version 3.9.6 installed into /usr/bin by Xcode. If I want that to be python 3.12.1, I need to place its path before PATH in the shell dot file.



For completeness, this is the tutorial I was following:
https://www.youtube.com/watch?v=GUBGoeCu19I&t=71s

That video is from over ten years ago. You cannot honestly expect that Apple has not significantly changed Xcode features or its interface since then? This is a "if I saw it on the Internet, then it must be true" bias and I always look for the date content was provided and form a declining relativity to a current operating system or application based on the content age.


Thanks again.


If you are not developing visual user interface applications in Swift, Objective-C, or C++, then you don't need Xcode as it is not a Python IDE. Frankly, the only IDE that I have used is the one supplied with Python3 named idle3 and then only for testing small instances of Python3 code to confirm results. Otherwise, I use Sublime Text 4 with the Anaconda Python IDE plug-in (not the Anaconda Python distribution) which gives me visual Python3 syntax checking.

Dec 27, 2023 9:10 AM in response to bojack_horseman

When you have installed Xcode and/or Command Line Tools for Xcode, they install and link an older (3.9.6) version of Python3 into /usr/bin/{python3, pip3}. Any third-party Python modules installed by that version of pip3 will be placed in:


~/Library/Python/3.9/lib/python/site-packages.


When you install Python3 (3.12.1) from Python.org, it is installed into:


/Library/Frameworks/Python.framework/Versions/3.12


and its binaries are linked into /usr/local/bin/{python3, idle3, pip3}. Any third-party Python modules are then installed into:


/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages.


So, it is very important that your PATH is correctly set to access the version of Python (and inherently, its modules) that you intend to use.


I can't help with developing Python code in Xcode as I hand code my GUI Python apps in Sublime Text 4 and then use the PyPy Pyinstaller tool to compile into a .app that responds like any other Mac App. Some of these, I have even converted to work-alike Swift UI applications.

Dec 27, 2023 7:14 PM in response to VikingOSX

Thank you both for your input. I normally develop my little Python scripts in Spyder or VS Code, and both are usable, but neither are amazing to be honest, plus VSCode is about to die on Mac.


So I was curious to see what Xcode had to offer. Not so much it seems for Python people! This is a shame, as I'd love to learn more about Xcode.


Regarding PATH, I can call python3 at any time from anywhere in Terminal, so I believe that must be set up properly. Also, by supplying the path to Xcode in the scheme, Xcode has the info it needs, but as I said, on second attempt the python3 file was greyed out. I wish it would let me select it and then produce an error - then I'd at least have a clue.


For completeness, this is the tutorial I was following:

https://www.youtube.com/watch?v=GUBGoeCu19I&t=71s

Thanks again.

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.

Xcode: Cannot select python3 as executable

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