Conda User's Guide
Conda is an open source package management and environment management system, which is able to install, manage packages and manage dependencies in a cross-platform way, especially suitable for Python and R language environment management. This article organizes the use of common Conda commands.
1. Install Miniconda
First, download the Miniconda installation script and execute the installation. Take the Linux AArch64 architecture as an example:
./
Follow the prompts to complete the installation.conda
will be automatically available.
2. Create and activate the Conda environment
Creating a Conda Environment
Use Conda to create a new virtual environment and specify the version of Python (Python 3.8, for example):
conda create -n machine_learning_env python=3.8
-
-n
parameter specifies the environment name, which in this case ismachine_learning_env
。 -
python=3.8
Specify Python version 3.8.
Activating the Conda environment
Once you have created the environment, activate it using the following command:
conda activate machine_learning_env
When the environment is activated, the command line prompt changes to(machine_learning_env)
, indicating that the environment is currently in use.
Dependencies for the installation environment
Normally we would have a file lists all the Python packages that need to be installed. Use the
pip
to install these dependent packages:
pip install -r
This command automatically retrieves the data from the to read and install all the specified packages.
Remove Conda environment
If you want to remove an environment (e.g.machine_learning_env
), use the following command:
conda env remove -n machine_learning_env
3. Managing Conda configuration
Displays the sources (Channels) for the Conda configuration
Conda uses sources (Channels) to find and download packages. You can use the following command to view the currently configured sources:
conda config --show channels
Display the source of the Conda configuration file
View the source path of the current Conda configuration file:
conda config --show-sources
Modifying Conda Configuration
Remove a specific source
If you need to delete a source, use the following command:
conda config --remove channels <channel_name>
Setting Conda to Display Source URLs
To make it easier to see the source address used during installation, you can configure Conda to display the source URL:
conda config --set show_channel_urls yes
4. Installation of dependent libraries
Installing individual packages
Installation with Condalibffi
Software packages:
conda install libffi
Installation of Conda-Pack
conda-pack
is a tool for packaging Conda environments into a zip file for easy migration or distribution.
mountingconda-pack
utilizationconda-forge
source installationconda-pack
:
conda install -c conda-forge conda-pack
Packaging Conda Environments
Packaging the specified environment (inmachine_learning_env
(for example):
conda pack -n machine_learning_env -o machine_learning_env.
-
-n machine_learning_env
Specifies the name of the environment to be packaged. -
-o machine_learning_env.
Specifies the name of the output zip file.
5. Other Common Conda Commands
Deactivate the current environment
If you no longer need to use the current environment, you can de-activate it using the following command:
conda deactivate