If the new MBPs (M1) come with Python3 pre-installed, why don’t Python scripts run in shell?
I've been reading through lots of "how to"s on using Homebrew to install Python3 and Python packages, but from my terminal queries, it looks to me that Python3 is already installed:
MBP21:~$ which python
/usr/bin/python
MBP21:~$ python --version
Python 2.7.18
MBP21:~$ python3 --version
Python 3.8.9
MBP21:~$ which python3
/usr/bin/python3
MBP21:~$ where python
/usr/bin/python
But when I started venv
, installed Django (successfully), and did manage.py runserver
, I got this message:
WARNING: The script sqlformat is installed in '/Users/ysl/Library/Python/3.8/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script django-admin is installed in '/Users/ysl/Library/Python/3.8/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed asgiref-3.4.1 backports.zoneinfo-0.2.1 django-4.0 sqlparse-0.4.2
And when I tried to use manage.py runserver
, I got this error message:
zsh: command not found: manage.py
I may be conflating different issues here, but am not sure where to start fixing the problem. Appreciate some tips.
Solution 1:
The warning is telling you that it installed binaries/scripts at a non-standard location that's not included in your PATH
. This means they won't be found when you simply enter their names like manage.py
without their full path.
You need to add /Users/ysl/Library/Python/3.8/bin
to your zsh PATH
(and then restart your shell/terminal).