1

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.

8
  • 2
    Did you add the directory to PATH as mentioned in the messages you got?
    – nohillside
    Commented Dec 22, 2021 at 6:19
  • 1
    How exactly are you using venv and how did you install the scripts
    – mmmmmm
    Commented Dec 22, 2021 at 10:09
  • 1
    Start with the python docs for venv docs.python.org/3/library/venv.html You have set up the environment but you are not using it. You need to activate it
    – mmmmmm
    Commented Dec 22, 2021 at 15:15
  • 1
    How EXACTLY did you do these things so we can reproduce. Nothing you have shown would try to put anything in Users/ysl/Library/Python/3.8/bin - unless you did it directly from python3 without activating a venv
    – mmmmmm
    Commented Dec 22, 2021 at 15:22
  • 1
    If you use venv USE venv Activating will change your paths for pip and python3 so that where will point to the correct venv
    – mmmmmm
    Commented Dec 22, 2021 at 15:56

1 Answer 1

2

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).

6
  • The link eventually leads to an article in dev.to, which I've read--but which circles me back to a fundamental confusion on my part (pardon the ignorance): By adding (exporting?) PATH, will the installation of Python in /Users/ysl/Library/Python/3.8/bin be accessible to other Django apps? If not, do I need to install a version of Django (maybe using Homebrew) to make Python work with all other Django apps? I'm hoping to keep the system clean and not have too many different installations as I did to the previous laptop.
    – YCode
    Commented Dec 22, 2021 at 14:47
  • 1
    This is sort of correct in that you need to add things to the path but if you are using venv then that is the wrong thing to add.
    – mmmmmm
    Commented Dec 22, 2021 at 15:17
  • Just realized (duh!) that VS Code complained the script not on the path of '/Users/ysl/Library/Python/3.8/bin'--which is a different path from /usr/bin/python3 where the Python 3.8 executable is located. What concept/keyword can I use to figure out the distinction btw the two?
    – YCode
    Commented Dec 22, 2021 at 15:17
  • 1
    The concept is venv - please read the manuals. venv alters your environment so each environment has a different path and version of python and libraries.
    – mmmmmm
    Commented Dec 22, 2021 at 15:58
  • @mmmmmm I get that. Tried multiple times to read the docs but, due to gaps in my knowledge, the docs left me more confused. Thanks-I'll try again.
    – YCode
    Commented Dec 22, 2021 at 16:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .