Wanna see something cool? Check out Angular Spotify 🎧

/usr/local/bin/code: line 6: python: command not found

Recently, when trying to run code . from terminal, I got the following error:

/usr/local/bin/code: line 6: python: command not found
/usr/local/bin/code: line 10: ./MacOS/Electron: No such file or directory

/usr/local/bin/code: line 6: python: command not found

After searching on google, I found that Github issue #141738. The problem was Apple removed support for Python 2 on macOS 12.3. Therefore when code is trying to run python command, it will fail.

To fix the issue, do the following steps.

I got mine working by:

  1. cd /usr/local/bin
  2. nano code
  3. change python => python3 on the following line
- function realpath() { python -c ...
+ function realpath() { python3 -c ...

To save the file on nano, press Ctrl + Option + o. Restart the terminal, and now code . works!

/usr/local/bin/code: line 6: python: command not found

Published 19 Apr 2022

    Read more

    Multiple ng-content
    My React Reading List
    Slick - prevent layout shift for your slider
    CSS div jumped when adding a border
    Align React Material UI Dialog to the top instead of center

    Follow @tuantrungvo on Twitter for more!