TensorFlow is a popular open-source library for machine learning. To install it you first need to install Python.
Please be advised that the exemplary Python and TensorFlow instructions serve only as an abstract reference to plain and simple estimators. Detailed instructions on using TensorFlow 2.x version will follow in subsequent materials.
If you would like to install the most recent version of Python with TensorFlow and scikit-learn to do some hands-on, please follow the instructions contained below, that are also additionally present in the updates list under the Plain and simple estimators topic of the EITC/AI/GCML Google Cloud Machine Learning available at https://eitca.org/programmes/eitc-ai-gcml-google-cloud-machine-learning/lessons/first-steps-in-machine-learning/topic/plain-and-simple-estimators/.
Please note however that you don’t have to delve in Python and TensorFlow in the EITC/AI/GCML certification programme, as it is not required, but if you’d like to, you are welcome. Please be advised that Python programming is fully covered in the EITC/CP/PPF Python Programming Fundamentals certification programme, available at https://eitca.org/programmes/eitc-cp-ppf-python-programming-fundamentals/.
Python is not required in the EITC/AI/GCML Google Cloud Machine Learning certification programme.
1. Install Python
Download Python
Visit the official Python website’s download section, Python Downloads at https://www.python.org/downloads/
Download the latest version for Windows (or for MacOS, or Linux depending on your system)
Install Python
Run the installer
Ensure “Add Python to PATH” is checked at the bottom
Click “Install Now”
2. Install Visual Studio Code
Download the VS Code
Visit the official VS Code website, Visual Studio Code at https://code.visualstudio.com/
Download the Windows version (or MacOS, or Linux version depending on your system)
Install VS Code
Run the installer and follow the installation prompts
Install Python Extension for VS Code
Open VS Code
Go to Extensions (you can use the shortcut Ctrl+Shift+X)
Search for “Python” and install the official Python extension provided by Microsoft
3. Install TensorFlow and scikit-learn
Open Command Prompt
In Windows system press Windows + R, type cmd, and press Enter
Install TensorFlow
Type pip install tensorflow and press Enter
Install scikit-learn:
Type pip install scikit-learn and press Enter
4. Set Up VS Code for Python Development
Open VS Code
Create a New Python File
Go to File > New File
Save it with a .py extension, for example, test.py
Select Python Interpreter
Press Ctrl+Shift+P to open the command palette
Type “Python: Select Interpreter” and select it
Choose the Python version you installed earlier
Write and Run Python Code
In test.py, write a simple Python code, e.g., print(“Hello, TensorFlow!”)
Right-click and select “Run Python File in Terminal” to execute the code
Test TensorFlow and scikit-learn
In the same test.py, add the following:
python
import tensorflow as tf
import sklearn
print(tf.__version__)
print(sklearn.__version__)
Run the file again as before to see the versions of TensorFlow and scikit-learn printed in the terminal
5. Explore and Code:
With everything set up, you can now use VS Code to develop Python applications, utilizing TensorFlow and scikit-learn. VS Code offers features like IntelliSense, debugging, and more, which will enhance your development experience
Remember to keep your packages updated regularly using pip to ensure you have the latest features and security patches
If you’re experincing problems in installing TensorFlow, you can follow these more detailed step-by-step instructions:
1. Choose the appropriate installation method: TensorFlow can be installed on various platforms, including Windows, macOS, and Linux. Before proceeding, ensure that your system meets the minimum requirements for TensorFlow installation.
2. Create a virtual environment (optional): It is recommended to create a virtual environment to isolate your TensorFlow installation from other Python packages. This step ensures that TensorFlow and its dependencies are installed in a separate environment, preventing conflicts with other packages. You can use tools like virtualenv or conda to create a virtual environment.
3. Install TensorFlow: Once you have set up your virtual environment (if desired), you can proceed with installing TensorFlow. There are multiple ways to install TensorFlow, depending on your system and requirements:
a. Installing with pip: The easiest way to install TensorFlow is by using pip, the Python package installer. Open a command prompt or terminal and run the following command:
pip install tensorflow
This will download and install the latest stable version of TensorFlow. If you want to install a specific version, you can specify it by adding the version number after the package name, like `tensorflow==2.3.0`.
b. Installing with Anaconda: If you are using the Anaconda distribution, you can install TensorFlow using conda, which is Anaconda's package manager. Open a command prompt or terminal and run the following command:
conda install tensorflow
This will download and install the latest version of TensorFlow available in the Anaconda repository.
c. Installing from source: If you prefer to build TensorFlow from source, you can follow the instructions provided in the TensorFlow documentation. Building from source gives you more control over the installation process and allows you to customize TensorFlow based on your specific needs.
4. Verify the installation: After the installation is complete, it is essential to verify that TensorFlow is working correctly. You can do this by importing TensorFlow in a Python script or interactive Python environment and checking for any error messages. Here's an example:
python
import tensorflow as tf
# Check TensorFlow version
print("TensorFlow version:", tf.__version__)
# Create a simple TensorFlow computation
a = tf.constant(2)
b = tf.constant(3)
c = tf.add(a, b)
# Run the computation and print the result
with tf.Session() as sess:
result = sess.run(c)
print("Result:", result)
Running this script should output the TensorFlow version and the result of the computation, which in this case is 5.
Please note that if you are using TensorFlow 2.x and wish to run the above code, you might need to enable compatibility mode in TensorFlow 2.x by adding over the previously indicated code the following:
python import tensorflow.compat.v1 as tf tf.disable_v2_behavior()
This will allow to run TensorFlow 1.x code in a TensorFlow 2.x environment.
Alternatively you can stick with TensorFlow 2.x eager execution, which is more intuitive and easier to use than the session-based execution of TensorFlow 1.x. In that case the code could be modified as follows:
python
import tensorflow as tf
# Check TensorFlow version
print("TensorFlow version:", tf.__version__)
# Create a simple TensorFlow computation
a = tf.constant(2)
b = tf.constant(3)
c = tf.add(a, b)
# Print the result
print("Result:", c.numpy())
Congratulations! You have successfully installed TensorFlow and verified its functionality. You can now start exploring the vast capabilities of TensorFlow for machine learning and deep learning tasks.
Other recent questions and answers regarding Plain and simple estimators:
- Do I need to install TensorFlow?
- I have Python 3.14. Do I need to downgrade to version 3.10?
- Are the methods of Plain and Simple Estimators outdated and obsolete or they still have value in ML?
- How do Keras and TensorFlow work together with Pandas and NumPy?
- Right now, should I use Estimators since TensorFlow 2 is more effective and easy to use?
- What is artificial intelligence and what is it currently used for in everyday life?
- How to use Google environment for machine learning and applying AI models for free?
- How Keras models replace TensorFlow estimators?
- How to use TensorFlow Serving?
- What is the simplest route to most basic didactic AI model training and deployment on Google AI Platform using a free tier/trial using a GUI console in a step-by-step manner for an absolute begginer with no programming background?
View more questions and answers in Plain and simple estimators

