Installing TensorFlow with pip
- Ensure your system has Python installed. TensorFlow supports Python versions 3.7 and newer. You can check your Python version by running the following command:
```shell
python --version
```
If Python is not installed, download and install it from the official Python website.
Use a virtual environment to create an isolated workspace for your Python projects. This helps manage dependencies and versions more efficiently. Set up a virtual environment by running:
```shell
python -m venv myenv
```
Activate the virtual environment:
Update pip to ensure you have the latest version. This helps avoid compatibility issues:
```shell
pip install --upgrade pip
```
Install TensorFlow using pip. Depending on your needs, you can choose between stable and nightly versions:
To install the latest stable version of TensorFlow:
```shell
pip install tensorflow
```
To install a specific version of TensorFlow:
```shell
pip install tensorflow==2.6.0
```
If you want to explore cutting-edge changes and features that might not yet be in the stable release, install the nightly build:
```shell
pip install tf-nightly
```
Verify the installation by running a simple script to check if TensorFlow is correctly installed. Open your Python interactive shell or create a new Python file and run:
```python
import tensorflow as tf
print(tf.**version**)
```
This should print the TensorFlow version number if the installation was successful.