Python Deep Learning - Environment Setup



In this chapter, we will learn about the environment set up for Python Deep Learning. We have to install the following software for making deep learning algorithms.

  • Python 2.7+
  • Scipy with Numpy
  • Matplotlib
  • Theano
  • Keras
  • TensorFlow

It is strongly recommend that Python, NumPy, SciPy, and Matplotlib are installed through the Anaconda distribution. It comes with all of those packages.

We need to ensure that the different types of software are installed properly.

Let us go to our command line program and type in the following command −

(myenv) D:\Projects\python\myenv>py
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Next, we can import the required libraries and print their versions −

>>>import numpy
>>>print(numpy.__version__)

Output

2.3.5

Installation of Theano, TensorFlow and Keras

Before we begin with the installation of the packages − Theano, TensorFlow and Keras, we need to confirm if the pip is installed. The package management system in Anaconda is called the pip.

To confirm the installation of pip, type the following in the command line −

(myenv) D:\Projects\python\myenv>pip3

Usage:
  pip3 <command> [options]

Commands:
  install                     Install packages.
  ...

Once the installation of pip is confirmed, we can install TensorFlow and Keras by executing the following command −

pip3 install tensorflow
...
Installing collected packages: namex, libclang, flatbuffers, wrapt, urllib3, typing_extensions, termcolor, tensorboard-data-server, six, setuptools, pygments, protobuf, pillow, packaging, opt_einsum, ml_dtypes, mdurl, markupsafe, markdown, idna, h5py, gast, charset_normalizer, certifi, absl-py, wheel, werkzeug, requests, optree, markdown-it-py, grpcio, google_pasta, tensorboard, rich, astunparse, keras, tensorflow
Successfully installed absl-py-2.4.0 astunparse-1.6.3 certifi-2026.1.4 charset_normalizer-3.4.4 flatbuffers-25.12.19 gast-0.7.0 google_pasta-0.2.0 grpcio-1.76.0 h5py-3.15.1 idna-3.11 keras-3.13.2 libclang-18.1.1 markdown-3.10.1 markdown-it-py-4.0.0 markupsafe-3.0.3 mdurl-0.1.2 ml_dtypes-0.5.4 namex-0.1.0 opt_einsum-3.4.0 optree-0.18.0 packaging-26.0 pillow-12.1.0 protobuf-6.33.5 pygments-2.19.2 requests-2.32.5 rich-14.3.1 setuptools-80.10.2 six-1.17.0 tensorboard-2.20.0 tensorboard-data-server-0.7.2 tensorflow-2.20.0 termcolor-3.3.0 typing_extensions-4.15.0 urllib3-2.6.3 werkzeug-3.1.5 wheel-0.46.3 wrapt-2.1.0

Confirm the installation of Tensorflow by executing the following line of code −

>>> import tensorflow
>>> print(tensorflow.__version__)

Output

2.20.0

Confirm the installation of Keras by executing the following line of code −

>>> import keras
>>> print(keras.__version__)

Output

3.13.2
Advertisements