x$ sudo apt-get update
$ sudo apt-get install python3-pip
$ sudo apt-get install build-essential python3-dev
$ pip3 install numpy
$ pip3 install scipy
$ pip3 install matplotlib
$ pip3 install scikit-learn
$ pip3 install tensorflow-cpu==2.10.0
$ pip3 install pillow
x
brew update
brew install python
xcode-select --install
pip3 install --upgrade pip
pip3 install numpy
pip3 install scipy
pip3 install matplotlib
pip3 install scikit-learn
pip3 install tensorflow-macos==2.12.0
pip3 install tensorflow-metal==1.0.0
pip3 install pillow
For TensorFlow, specify version 2 to ensure that the proper version of the Keras library is included.
Metal is Apple’s low-level, high-performance graphics and compute API that provides direct access to the GPU.
The Pillow library is an image-processing library
Matplotlib is for plotting.
Tensorflow for MacOS currently (8/26/2025) requires python 3.9 or 3.10, it won't work with newer versions
xxxxxxxxxx
brew install python@3.10
This will install Python 3.10 on your computer at a location like: /usr/local/bin/python3.10
Navigate to your project directory or create one:
x
mkdir Projects/pdl
cd Projects/pdl
Then create the virtual environment1:
x
/usr/local/bin/python3.10 -m venv
This creates a folder named venv
containing the isolated Python environment.
x
source venv/bin/activate
Your terminal prompt will change to show you're inside the virtual environment. Now any pip3 install
commands will apply only to this project.
Install the dependencies for this project:
xxxxxxxxxx
pip3 install --upgrade pip
pip3 install numpy
pip3 install scipy
pip3 install matplotlib
pip3 install scikit-learn
pip3 install tensorflow-macos==2.12.0
pip3 install tensorflow-metal==1.0.0
pip3 install pillow
To exit the virtual environment:
xxxxxxxxxx
deactivate
AI Programming lecture notes by Brian Bird, written in , are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
MS Copilot GPT-4 was used to draft parts of these notes.