Introduction to Conda Environment

Provides a quick introduction about the Conda environment, its file directories and command programs. Steps to verify its Python version, and install new packages.

After installing Miniconda, we should take a quick tour on the "base" environment it offers.

1. Conda "base" environment program files are located in ~/miniconda3. They look very much like a mini operating system.

drwxrwxr-x.  2 herong herong  4096 bin
drwxrwxr-x.  2 herong herong    30 compiler_compat
drwxrwxr-x.  2 herong herong    19 condabin
drwxrwxr-x.  2 herong herong  4096 conda-meta
drwxrwxr-x.  2 herong herong     6 envs
drwxrwxr-x.  4 herong herong    35 etc
drwxrwxr-x.  9 herong herong  4096 include
drwxrwxr-x. 15 herong herong  4096 lib
-rw-r--r--.  1 herong herong 11245 May 19 15:29 LICENSE.txt
drwxrwxr-x. 61 herong herong  8192 pkgs
drwxrwxr-x. 10 herong herong   116 share
drwxrwxr-x.  3 herong herong    22 shell
drwxrwxr-x.  3 herong herong   146 ssl
drwxrwxr-x.  3 herong herong    21 x86_64-conda_cos6-linux-gnu

2. Commands (some of them override system commands) provided by Conda are located in ~/miniconda3/bin.

lrwxrwxrwx. 1 herong herong        8 2to3 -> 2to3-3.8
-rwxrwxr-x. 1 herong herong      114 2to3-3.8
-rwxrwxr-x. 1 herong herong      197 activate
lrwxrwxrwx. 1 herong herong        3 captoinfo -> tic
-rwxrwxr-x. 1 herong herong      243 chardetect
-rwxrwxr-x. 2 herong herong    14288 clear
-rwxrwxr-x. 1 herong herong      524 conda
-rwxrwxr-x. 1 herong herong      161 conda-env
-rwxrwxr-x. 1 herong herong      247 cph
-rwxrwxr-x. 1 herong herong     6214 c_rehash
-rwxrwxr-x. 1 herong herong      285 deactivate
-rwxrwxr-x. 1 herong herong      252 easy_install
lrwxrwxrwx. 1 herong herong        7 idle3 -> idle3.8
-rwxrwxr-x. 1 herong herong      112 idle3.8
-rwxrwxr-x. 2 herong herong    63512 infocmp
lrwxrwxrwx. 1 herong herong        3 infotocap -> tic
lrwxrwxrwx. 1 herong herong        2 lzcat -> xz
...
-rwxrwxr-x. 2 herong herong    21216 lzmadec
-rwxrwxr-x. 1 herong herong    21128 lzmainfo
lrwxrwxrwx. 1 herong herong        6 lzmore -> xzmore
-rwxrwxr-x. 1 herong herong     8076 ncursesw6-config
-rwxrwxr-x. 2 herong herong   836336 openssl
-rwxrwxr-x. 1 herong herong      243 pip
lrwxrwxrwx. 1 herong herong        8 pydoc -> pydoc3.8
lrwxrwxrwx. 1 herong herong        8 pydoc3 -> pydoc3.8
-rwxrwxr-x. 1 herong herong       97 pydoc3.8
lrwxrwxrwx. 1 herong herong        9 python -> python3.8
lrwxrwxrwx. 1 herong herong        9 python3 -> python3.8
-rwxrwxr-x. 2 herong herong 14707712 python3.8
-rwxrwxr-x. 1 herong herong     3498 python3.8-config
lrwxrwxrwx. 1 herong herong       16 python3-config -> python3.8-config
lrwxrwxrwx. 1 herong herong        4 reset -> tset
-rwxrwxr-x. 2 herong herong  1508240 sqlite3
-rwxrwxr-x. 2 herong herong    29841 sqlite3_analyzer
-rwxrwxr-x. 2 herong herong    14280 tabs
lrwxrwxrwx. 1 herong herong        8 tclsh -> tclsh8.6
-rwxrwxr-x. 2 herong herong    20616 tclsh8.6
-rwxrwxr-x. 2 herong herong    88128 tic
-rwxrwxr-x. 2 herong herong    22472 toe
-rwxrwxr-x. 2 herong herong    22504 tput
-rwxrwxr-x. 1 herong herong      231 tqdm
-rwxrwxr-x. 2 herong herong    30672 tset
lrwxrwxrwx. 1 herong herong        2 unlzma -> xz
lrwxrwxrwx. 1 herong herong        2 unxz -> xz
-rwxrwxr-x. 1 herong herong      230 wheel
lrwxrwxrwx. 1 herong herong        7 wish -> wish8.6
-rwxrwxr-x. 2 herong herong    20768 wish8.6
-rwxrwxr-x. 2 herong herong  2709960 x86_64-conda_cos6-linux-gnu-ld
...

3. Python version in Conda environment could be different:

herong$ python3 --version
Python 3.6.8

herong$ conda activate
(base) herong$ python3 --version
Python 3.8.3

5. Python libraries, like NumPy, need to be installed in Conda environment. This is done by the "conda install ..." command, instead of the "pip install ...". A Python library is a Conda package, from Conda's point of view.

herong$ python
Python 3.8.3 (default, May 19 2020, 18:47:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux

>>> import numpy
ModuleNotFoundError: No module named 'numpy'

>>> exit()

(base) herong$ conda install numpy
## Package Plan ##

  environment location: /home/herong/miniconda3
  added / updated specs:
    - numpy

The following NEW packages will be INSTALLED:
  blas               pkgs/main/linux-64::blas-1.0-mkl
  intel-openmp       pkgs/main/linux-64::intel-openmp-2020.1-217
  mkl                pkgs/main/linux-64::mkl-2020.1-217
  mkl-service        pkgs/main/linux-64::mkl-service-2.3.0-py38he904b0f_0
  mkl_fft            pkgs/main/linux-64::mkl_fft-1.1.0-py38h23d657b_0
  mkl_random         pkgs/main/linux-64::mkl_random-1.1.1-py38h0573a6f_0
  numpy              pkgs/main/linux-64::numpy-1.19.1-py38hbc911f0_0
  numpy-base         pkgs/main/linux-64::numpy-base-1.19.1-py38hfa32c7d_0

The following packages will be UPDATED:
  ca-certificates                          2020.1.1-0 --> 2020.6.24-0
  certifi                           2020.4.5.1-py38_0 --> 2020.6.20-py38_0
  conda                                  4.8.3-py38_0 --> 4.8.4-py38_0

Proceed ([y]/n)? y

Downloading and Extracting Packages
mkl-2020.1           | 129.0 MB  | ##################... | 100%
intel-openmp-2020.1  | 780 KB    | ##################... | 100%
mkl_random-1.1.1     | 341 KB    | ##################... | 100%
certifi-2020.6.20    | 156 KB    | ##################... | 100%
ca-certificates-2020 | 125 KB    | ##################... | 100%
numpy-1.19.1         | 21 KB     | ##################... | 100%
conda-4.8.4          | 2.8 MB    | ##################... | 100%
numpy-base-1.19.1    | 4.2 MB    | ##################... | 100%
mkl_fft-1.1.0        | 150 KB    | ##################... | 100%
mkl-service-2.3.0    | 62 KB     | ##################... | 100%
blas-1.0             | 6 KB      | ##################... | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

herong$ python
Python 3.8.3 (default, May 19 2020, 18:47:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux

>>> import numpy as np
>>> np.v1.32
'1.19.1'

Table of Contents

 About This Book

 Introduction to Linux Systems

 Cockpit - Web Portal for Administrator

 Process Management

 Files and Directories

 Users and Groups

 File Systems

 Installing CentOS

 SELinux - Security-Enhanced Linux

 Network Connection on CentOS

 Software Package Manager on CentOS - DNF and YUM

 Running Apache Web Server (httpd) on Linux Systems

 Running PHP Scripts on Linux Systems

 Running MySQL Database Server on Linux Systems

 Running Python Scripts on Linux Systems

 vsftpd - Very Secure FTP Daemon

 Postfix - Mail Transport Agent (MTA)

 Dovecot - IMAP and POP3 Server

 Email Client Tools - Mail User Agents (MUA)

 GCC - C/C++ Compiler

Conda - Environment and Package Manager

 What Is Conda

 Install Miniconda 3

Introduction to Conda Environment

 Tools and Utilities

 References

 Full Version in PDF/EPUB