django-admin startproject problem


I have several Django projects on my Mac but now if I try to make a new project like this:
django-admin startproject app

it gives me the following error:

Traceback (most recent call last):
  File "/usr/local/bin/django-admin", line 6, in <module>
    from import execute_from_command_line
ModuleNotFoundError: No module named 'django'

This is strange to me but I tried to (re)install django but:

Requirement already satisfied: django in /usr/local/lib/python3.9/site-packages (3.1)
Requirement already satisfied: sqlparse>=0.2.2 in /usr/local/lib/python3.9/site-packages (from django) (0.4.1)
Requirement already satisfied: asgiref~=3.2.10 in /usr/local/lib/python3.9/site-packages (from django) (3.2.10)
Requirement already satisfied: pytz in /usr/local/lib/python3.9/site-packages (from django) (2020.5)

What should I do?

I’m not a consistent Mac user, so I don’t know how to “fix” this specific issue. But my general response to situations like this are to create a new virtual environment and install the necessary packages in it. (If you’re not using virtual environments for your development environment, you should.)