Requirement: I have a script that has a python command to run and the script is used by everyone
Error: python: command not found
Example:
cat test.sh
python -c "import json,sys;"
If I change the script from python -c
to python3 -c
it works fine
Also, my ~/.zshrc as below
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
alias python=/usr/bin/python3
alias pip=/usr//bin/pip3
I already have python on my macOS as below
Issue is when running python inside the shellscript
How to get the shell script to run the python command in it?
Also why is it blank when running below command
CodePudding user response:
As suggested by the homebrew installer itself, be sure to add this to your .bashrc or .zshrc:
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
:( Above worked only one time but next time i ran it threw same error python command not found
CodePudding user response:
Finally below solved my problem
sudo ln -s /usr/bin/python3 /usr/local/bin/python