[Fix] env python No such file or directory when building app with Xcode

The Error “env: python: No such file or directory when building app with Xcode”, is an error that is invoked whenever you trying to build an app on Xcode using your mac. Given below is the snippet of the error you might get:

env: python: No such file or directory
Command Ld failed with a nonzero exit code

I would like to share with you the steps I took to fix the “env: python: No such file or directory when building app with Xcode” in your project file.

Why “Error while fetching extensions. XHR failed” Error is Seen?

The error, “env: python: No such file or directory when building app with Xcode” is seen because during the installation Homebrew also installs the binary python3. So, Xcode is throwing an error about a lack of the binary python, not about python3.

The detailed solution to fix the error “env: python: No such file or directory when building app with Xcode”, is given below:

How to Fix env python No such file or directory when building app with Xcode Error?

To fix the env python No such file or directory when building app with Xcode error, you have to create appropriate symlinks to python and add it to the directory which you are using.

To fix the error, “env: python: No such file or directory when building app with Xcode”, you have to follow the one of the below mentioned methods:

Method 1: Directly adding symlinks

Whenever you are installing python3, Homebrew also creates a libexec folder with unversioned symlinks, such as python, which is causing the error. Note the code printed when installing it

:$ brew info python python@3.9: stable 3.9.10 (bottled) ==> Caveats Python has been installed as 
/opt/homebrew/bin/python3 Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to `python3`, `python3-config`, `pip3` etc., respectively, have been installed into /opt/homebrew/opt/python@3.9/libexec/bin See: https://docs.brew.sh/Homebrew-and-Python 

You have to add this directory to your $PATH, so that that python and pip become available; follow the below-mentioned code to do so:

echo 'export PATH="'"$(brew --prefix)"'/opt/python@3.9/libexec/bin:$PATH"' \ >>~/.bash_profile ...

Make a note that the above will have to be modified according to your precise version of Python3, your shell of choice, etc.

This should fix the error, “env: python: No such file or directory when building app with Xcode”.

Method 2: Manually adding symlinks

Alternative to the above method, there is a much simpler method, you could simply manually create the appropriate symlinks by following the below mentioned code:

ln -s "$(brew --prefix)/bin/python"{3,}

This should fix the error, “env: python: No such file or directory when building app with Xcode”.

Conclusion

To fix the error “env: python: No such file or directory when building app with Xcode”, you have to create appropriate symlinks to python and add it to the directory which you are using.