pythonmacospipmacos-ventura

System cannot identify installed Python packages


Any package installed through pip3 is declared to be 'successfully installed' but cannot be identified despite the path being included in the the $PATH environment variable.

So far have attempted the following:

The issue is demonstrated below in the project directory antons_pizza on macOS Ventura 13.4 with zsh shell.

➜ echo $PATH                            
/usr/local/lib/python3.11/site-packages:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages:/Library/Frameworks/Python.framework/Versions/3.11/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin

➜  antons_pizza pip3 show django                           
Name: Django
Version: 4.2.2
Summary: A high-level Python web framework that encourages rapid development and clean, pragmatic design.
Home-page: https://www.djangoproject.com/
Author: Django Software Foundation
Author-email: foundation@djangoproject.com
License: BSD-3-Clause
Location: /usr/local/lib/python3.11/site-packages
Requires: asgiref, sqlparse
Required-by: 

➜  antons_pizza django admin startproject antons_pizza     
zsh: permission denied: django

➜  antons_pizza sudo django admin startproject antons_pizza
sudo: django: command not found

Then in the venv

➜  antons_pizza source antons_pizza_venv/bin/activate
(antons_pizza_venv) ➜  antons_pizza pip3 install django
Requirement already satisfied: django in ./antons_pizza_venv/lib/python3.11/site-packages (4.2.2)
Requirement already satisfied: asgiref<4,>=3.6.0 in ./antons_pizza_venv/lib/python3.11/site-packages (from django) (3.7.2)
Requirement already satisfied: sqlparse>=0.3.1 in ./antons_pizza_venv/lib/python3.11/site-packages (from django) (0.4.4)
(antons_pizza_venv) ➜  antons_pizza django admin startproject antons_pizza     
zsh: permission denied: django
(antons_pizza_venv) ➜  antons_pizza sudo django admin startproject antons_pizza
Password:
sudo: django: command not found

Solution

  • Answered in the comments by @FlyingTeller, alas it was a simple typo.

    I was trying to run django admin when the command is in fact django-admin.