Getting to grips with Python's Anaconda distribution

Anaconda is a free Python distribution developed by Continuum Analytics that is made for scientific computing. It works across Windows, Linux, and macOS X platforms and is free, even for commercial use. However, the best thing about it is that it comes with a number of preinstalled packages that are essential for data science, math, and engineering. These packages include the following:

  • NumPy: A fundamental package for scientific computing in Python that provides functionality for multidimensional arrays, high-level mathematical functions, and pseudo-random number generators
  • SciPy: A collection of functions for scientific computing in Python that provides advanced linear algebra routines, mathematical function optimization, signal processing, and so on
  • scikit-learn: An open source machine learning library in Python that provides useful helper functions and infrastructure that OpenCV lacks
  • Matplotlib: The primary scientific plotting library in Python, which provides functionality for producing line charts, histograms, scatter plots, and so on
  • Jupyter Notebook: An interactive environment for the running of code in a web browser that also includes functionalities of markdown, which in turn helps in maintaining well commented and detailed project notebooks

An installer for our platform of choice (Windows, macOS X, or Linux) can be found on the Continuum website, https://www.anaconda.com/download. I recommend using the Python 3.6-based distribution, as Python 2 is no longer under active development.

To run the installer, do one of the following:

  • On Windows, double-click on the .exe file and follow the instructions on the screen
  • On macOS X, double-click on the .pkg file and follow the instructions on the screen
  • On Linux, open a Terminal and run the .sh script using bash as shown here:
      $ bash Anaconda3-2018.12-Linux-x86_64.sh  # Python 3.6 based

In addition, Python Anaconda comes with conda—a simple package manager similar to apt-get on Linux. After successful installation, we can install new packages by typing the following command in the Terminal:

$ conda install package_name

Here, package_name is the actual name of the package that we want to install.

Existing packages can be updated using the following command:

$ conda update package_name

We can also search for packages using the following command:

$ anaconda search -t conda package_name

This will bring up a whole list of packages made available by developers. For example, searching for a package named opencv, we get the following hits:

This will bring up a long list of users who have OpenCV packages installed, allowing us to locate users that have our version of the software installed on our own platform. A package called package_name from a user called user_name can then be installed as follows:

$ conda install -c user_name package_name

Finally, conda provides something called an environment, which allows us to manage different versions of Python and/or packages installed in them. This means we could have a separate environment where we have all packages necessary to run OpenCV 4.1 with Python 3.6. In the following section, we will create an environment that contains all the packages needed to run the code in this book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.219.4.174