After installing python you should install virtualenv which will allow you to have different python environments with different dependencies without package version conflicts. Once activated the virtual environment is available globally until deactivated.

1. Create New Virtual Environment

Consider creating a directory to store all your different python environments or associate the python virtual environment within a specific project folder of something that you are working on.

Use the following command (once) to create the virtual python env (and folder) in your current working directory

virtualenv {newenvfoldername}

eg virtualenv testpyenv

2. Activate Environment

Use the following command to switch to this environment

source {envfolder}/bin/activate

eg source testpyenv/bin/activate

3. Determining Current Virtual/Python Environment

After activating the python env (testpyenv in this example), the env name will be added to your prompt, eg

(testpyenv) me@laptop pyenvs %

You can also verify using which

(testpyenv) me@laptop pyenvs % which python
/Users/me/work/pyenvs/testpyenv/bin/python

4. Package Management

To see what packages are installed using the following command

pip list

(testpyenv) me@laptop pyenvs % pip list
Package Version
------- -------
pip     25.1.1

To install a package in the virtualenv use pip

Here we will install numpy

(testpyenv) me@laptop pyenvs % pip install numpy
Collecting numpy
  Downloading numpy-2.2.5-cp313-cp313-macosx_14_0_arm64.whl.metadata (62 kB)
Downloading numpy-2.2.5-cp313-cp313-macosx_14_0_arm64.whl (5.1 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.1/5.1 MB 7.0 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-2.2.5

5. Deactivate Environment

To deactivate the environment use the deactivate command

(testpyenv) me@laptop pyenvs % deactivate
me@laptop pyenvs % 

Notice that the prompt changes to reflect that no virtual python environment is active any more

6. Deleting An Environment

After making sure that you are not actively using the virtual environment that you want to delete, you can simply delete the folder containing the virtual environment.

rm -rf ~/pyenvs/testpyenv

7. References

See this Youtube Tutorial for a longer explanation