Lab00 - Windows Installation
0.1 Windows
Step 1: Install Python on Windows 11
- Download Python
- Visit the official Python website: https://www.python.org/
- Download the latest stable version of Python (as of now, Python 3.12.5 or higher is recommended)
- Install Python:
- Run the Python installer once it is downloaded.
- On the first screen, click Customize Installation.
- Verify the Python Installation
- Click the Start menu and type "cmd" in the search bar. Press Enter to open the Command Prompt.
- Once the installation completes, open the Command Prompt:
- Type the following command to check the Python version:
python --version - This command should return the version of Python you just installed. If you see the version number, Python has been installed successfully.
Step 2: Set Up a Virtual Environment for TensorFlow
- Install Virtualenv:
- Still in the Command Prompt, install virtualenv by running:
pip install virtualenv
- Still in the Command Prompt, install virtualenv by running:
- Create a New Virtual Environment:
- Navigate to the directory where you want to create your virtual environment. For example, if you want to create it in a folder named TensorFlowEnv on your desktop:
cd %USERPROFILE%\Desktop
mkdir TensorFlowEnv
cd TensorFlowEnv - Create a new virtual environment using virtualenv. Here, tf2 is the name of the virtual environment:
virtualenv --system-site-packages -p python ./tf2
- Navigate to the directory where you want to create your virtual environment. For example, if you want to create it in a folder named TensorFlowEnv on your desktop:
- Activate the Virtual Environment:
- To activate the virtual environment, navigate to the Scripts folder within the virtual environment and run the activation script:
cd tf2\Scripts
activate - You should see (tf2) at the beginning of the command line prompt, indicating that the virtual environment is active.
- To activate the virtual environment, navigate to the Scripts folder within the virtual environment and run the activation script:
- Upgrade pip:
- It’s always good practice to upgrade pip to the latest version to avoid any issues:
pip install --upgrade pip
- It’s always good practice to upgrade pip to the latest version to avoid any issues:
- Verify pip Version:
- Confirm that pip has been upgraded by checking its version:
pip --version
- Confirm that pip has been upgraded by checking its version:
Step 3: Install TensorFlow 2
- Install the Current Stable Release of TensorFlow:
While in the activated virtual environment, install TensorFlow by running:
pip install tensorflow
This will install the CPU version of TensorFlow by default. If you have a GPU and want to install the GPU version, you can run:
pip install tensorflow-gpu
TensorFlow will be installed along with its dependencies. - Verify the TensorFlow Installation:
To check if TensorFlow has been installed correctly, open Python in the command prompt:
python
Once in the Python shell, type the following commands:
import tensorflow as tf
print(tf.__version__)
This should print the version of TensorFlow that was installed. - Exit the Virtual Environment:
After confirming the installation, you can deactivate the virtual environment by running:
deactivate
Using a virtual environment, you have successfully installed TensorFlow 2 on your Windows 11 machine. This setup ensures that your TensorFlow installation is isolated from other Python projects on your system, preventing potential conflicts.
If you encounter any issues during installation, ensure your Python and pip versions are up-to-date, and verify that all environment variables are set correctly.