Share
Explore

How to install the Python libraries you need for AML 3304 Course Project: Building a Simple Generative AI Language Model

Last edited 140 days ago by Peter Sigurdson
Start by installing the latest Anaconda Distribution.
I will recommend doing your work in Google Collab NB.



See the wrapper code to assemble together the Pythonic Tasks you must perform to do this:

What to read after this Tutorial:
The Prof’s Recommendations:
Get the latest version of Anaconda Python: This is the “Data Science” distro of Python.
Step 1: Installing Required Libraries
TensorFlow
Keras
NumPy
Pandas
Matplotlib
To install the required Python libraries for your project, you can use pip, the package installer for Python. Open a terminal or command prompt and run the following commands:
TensorFlow:

pip install tensorflow

Keras:
Keras is now part of TensorFlow, so you don't need to install it separately. You can import it using TensorFlow as follows:

import tensorflow as tf
from tensorflow import keras

NumPy:

pip install numpy

Pandas:

pip install pandas

Matplotlib:

pip install matplotlib

If you want to install all the libraries in one command, you can run:


pip install tensorflow numpy pandas matplotlib

If you're using a Jupyter Notebook or Google Colab, add an exclamation mark at the beginning of each command, like this:

!pip install tensorflow numpy pandas matplotlib

After installing the libraries, you can import them in your Python script or notebook as follows:

import tensorflow as tf
from tensorflow import keras
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt


To check the version of Python installed on your system, open a terminal or command prompt and run:

python --version

If you're using a version of Python older than 3.6, you should update to a newer version. You can download the latest version of Python from the Anacondo website:
If you want to use a specific version of Python or manage multiple Python environments, consider using a tool like pyenv () or creating a virtual environment using venv () or conda () to isolate your project dependencies.
For example, to create a virtual environment using venv:
Open a terminal or command prompt.
Navigate to the directory where you want to create the virtual environment.
Run the following command to create a virtual environment named "env" with Python 3.8 (replace "3.8" with your desired Python version):

python3.8 -m venv env

Activate the virtual environment:
On Linux or macOS:

source env/bin/activate

On Windows:

env\Scripts\activate

Now you can install the required libraries as mentioned in the previous answer, and they will be installed only within the virtual environment, isolated from your system Python installation.
Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.