Hands-On Deep Learning Architectures with Python
上QQ阅读APP看书,第一时间看更新

Setting up the environment

It's always a good practice to work on projects in separate environments. An environment is a space that keeps the libraries and dependencies, which are installed inside it, isolated from the global space of the operating system. Suppose you have to work on two projects; one requires an older version of a library and the other uses a newer version. In this situation, installing the newer version globally would overwrite the older version and make the first project unusable. However, you can create two separate environments for the two projects and install the required versions separately. Hopefully, you now get the idea behind working in environments.

We will use Miniconda, which is a small part of open source Python package management and distribution Anaconda. Conda is the package manager in Miniconda that aids in installing and managing packages with Python.

We will follow this step-by-step procedure to set up our working environment with Conda:

  1. Download Miniconda for Python 3.7 according to your operating system from https://conda.io/en/latest/miniconda.html. Install Miniconda by simply running the downloaded file.
  1. You may want to create a separate directory for storing the codes that we will be covering in this book. Let's call it the deep_learning directory. Pull up a Terminal and change to the following directory, in case you wish to upgrade to the latest version of Conda and upgrade packages:
conda upgrade conda
conda upgrade --all
  1. Now we will use Conda to create our working environment. Issue the following command into your Terminal window. Name the environment what you want; we name it test_env here:
conda create -n test_env
  1. To activate the environment, issue the following command:
conda activate test_env
  1. To deactivate the environment when you are done, issue the following command in the Terminal window:
  conda deactivate
Inside the environment created with Conda , you can use both pip (default package manager for Python) and Conda (package manager for Anaconda) to install libraries.

To view the packages that are installed in your environment, you can use the following command:

conda list

It will show the packages, irrespective of whether they are installed with conda or pip.