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

Python Faysal Shuvo

Problem: 

Using python, I created an app. And unknowingly I change some code in my python environment. I can not figure out what is wrong. When I run my app I encounter this error: 

env: python: No such file or directory

So, in this article, we are going to learn how to solve env: python: No such file or directory when building app with Xcode error.


Solution: 

The lack of python is what Xcode is complaining about. To solve this you have a couple of options: 

1. You could just manually create the symlinks: 

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

or, 

2. Homebrew creates libexec folder with unversioned symlinks when you install python3. Do this: 

$ 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

You could add this directory to your $PATH, so python and pip are available.

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

And now you can modify according to python3.


I hope this solves your problem. If you have any kind of problem please comment.