On my M2 Mac, Python makefile does not work. I'm running everything in iterm2.
test-local:
TREE_SITTER_LIB_PATH=./test python -m pytest
Error when running makefile:
➜ make test-local
/bin/sh: python: command not found
make: *** [test-local] Error 127
Python path:
➜ which -a python
python: aliased to /usr/local/bin/python3.9
➜ python
Python 3.9.17 (main, Jun 20 2023, 17:20:08)
[Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
My .zshrc file. I read other SOF articles so I tried adding to my path to no avail.
alias python=python3
PYTHON="$PATH:/Users/lewis.chi/Library/Python/3.9/bin"
PYTHON1="/usr/local/bin/python3.9"
PYTHON11="/usr/local/bin/"
export PATH=$PATH:$PYTHON:\$PYTHON1:\$PYTHON11
This is your problem:
➜ which -a python
python: aliased to /usr/local/bin/python3.9
This implies that python
is a shell alias. Shell aliases are local to the shell that you're using, they are not exported to sub-shells and make
doesn't know anything about aliases. So, you cannot run aliases from within make recipes.
If you want to make this work, you have to find a different way. You can use a make variable and set it to the right value on the command line, you can use a python
script instead of an alias, you can make python
a symbolic link to python3
, etc. etc.
But you cannot use a shell alias.
Ditto for shell functions, by the way: they are also local to the shell and not exported.