Python Tutorials - Herong's Tutorial Examples - v2.14, by Herong Yang
Manage Packages in Conda Environment
This section provides tutorial examples on how to install specific versions of packages from different sources in Anaconda environments.
One main feature of using Anaconda environments is that third party Python packages (libraries) are installed and managed independently in each Anaconda environment.
This is very important if you have multiple Python applications that require different combinations of third party packages and versions.
Here are some examples of Anaconda commands that may help you to install and manage third party Python packages.
Install the Latest Version - The following command installs the latest version of "numpy" in the active environment:
(base) herong$ conda install numpy The following NEW packages will be INSTALLED: numpy pkgs/main/linux-64::numpy-1.19.1-py38hbc911f0_0 numpy-base pkgs/main/linux-64::numpy-base-1.19.1-py38hfa32c7d_0 ...
Display the Installed Version - The following command displays the version of a package currently installed in the active environment:
(base) herong$ conda numpy numpy 1.19.1 py38hbc911f0_0 ...
Install a Specific Version - The following command installs an older version of "numpy" in the active environment:
(base) herong$ conda install numpy=1.19.0 The following packages will be downloaded: numpy-1.19.0 | py38h8854b6b_0 5.2 MB conda-forge ... The following packages will be REMOVED: numpy-base-1.19.1-py38hfa32c7d_0
Install from a TAR File - The following command installs a package from a local TAR file in the active environment:
(base) herong$ conda install packages-filename.tar ...
Install from "conda-forge" Channel - By default, packages are installed from the default channel (repository) at https://repo.anaconda.com/pkgs/main/. If the package is provided in the "conda-forge" channel at https://conda.anaconda.org/conda-forge, you can specify it in the "-c" or ""--channel" option as shown below:
(base) herong$ conda install openssl --channel conda-forge ... (base) herong$ conda install openssl \ --channel https://conda.anaconda.org/conda-forge
Add "conda-forge" Channel in Configuration - You can also add additional channels in your configuration file to avoid typing the "-c" or ""--channel" option:
(base) herong$ conda config --add channels conda-forge ... (base) herong$ conda config --add channels \ https://conda.anaconda.org/conda-forge ...
Examples of Channel Mirrors - If you having trouble reaching Anaconda official channels, you can try some channel mirrors like:
https://mirrors.ustc.edu.cn/anaconda/pkgs/main https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge https://mirrors.sustech.edu.cn/anaconda/pkgs/main/ https://mirrors.sustech.edu.cn/anaconda/pkgs/free/
Table of Contents
Variables, Operations and Expressions
Function Statement and Function Call
Iterators, Generators and List Comprehensions
Packages and Package Directories
"pathlib" - Object-Oriented Filesystem Paths
"pip" - Package Installer for Python
SciPy.org - Python Libraries for Science
pandas - Data Analysis and Manipulation
►Anaconda - Python Environment Manager
Introduction to Conda Environment
Share Conda Environment with Others
►Manage Packages in Conda Environment
Run Conda Environment Command in Background