Python packages

🔒 You must be logged in as an Administrator or Editor to listen to this audio.

Managing Python environments on macOS can feel like playing a game of "Where's Waldo" with your packages. The short answer: Packages are installed into the specific environment tied to the pip command you use.

If you just type pip install, it defaults to whatever Python is currently first in your system's PATH.


1. Where do the packages go?

Each of your paths represents a distinct "silo." When you run an install command, the packages are tucked away in a site-packages folder unique to that executable.

Python Executable Path Common site-packages Location
/usr/local/bin/python /usr/local/lib/pythonX.X/site-packages
/Users/joseph/anaconda3/bin/python /Users/joseph/anaconda3/lib/pythonX.X/site-packages
/Users/joseph/anaconda3/envs/py3119/bin/python /Users/joseph/anaconda3/envs/py3119/lib/python3.11/site-packages

How to be 100% sure:

The safest way to install packages to a specific environment is to call that Python binary directly with the -m pip flag. This ensures the package goes exactly where that Python lives:

# To install specifically to your 'py3119' environment:
/Users/joseph/anaconda3/envs/py3119/bin/python -m pip install -r requirements.txt

2. How to find the exact install path

If you've already installed a package (e.g., requests) and want to see where it landed, run:

pip show requests

Look for the Location: line in the output.


3. How to delete them

There are two ways to "delete" depending on whether you want to remove specific packages or the whole environment.

Option A: Uninstalling specific packages

To remove everything listed in your requirements.txt from the current environment:

pip uninstall -r requirements.txt -y

Option B: Deleting the entire environment (Recommended for Conda)

Since you are using Anaconda, you shouldn't manually delete folders for your py3119 environment. Use the conda command instead:

conda env remove -n py3119

Option C: Manual "Nuclear" Option

If you want to wipe the site-packages manually (use caution!):

  1. Find the location using pip show.
  2. Navigate to that site-packages folder in Finder or Terminal.
  3. Delete the folders corresponding to the library name and its .dist-info.

Pro-Tip: The which command

To see which pip your terminal is currently using by default, type:

which pip

If it returns /usr/local/bin/pip, any simple pip install command will go to your system/Homebrew Python, not your Anaconda environments. Always activate your environment first using conda activate py3119.

Which of these environments are you planning to use as your main workspace?