0% found this document useful (0 votes)
17 views7 pages

Conda Chatgpt

The document provides a comprehensive guide to commonly used Conda commands for package and environment management in Python. It includes commands for installation, environment creation, package management, exporting/importing environments, and cleaning up. Additionally, it offers an example workflow and instructions for creating environments in the current working directory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views7 pages

Conda Chatgpt

The document provides a comprehensive guide to commonly used Conda commands for package and environment management in Python. It includes commands for installation, environment creation, package management, exporting/importing environments, and cleaning up. Additionally, it offers an example workflow and instructions for creating environments in the current working directory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Conda commands

Conda is a powerful package management and environment management tool for


Python and other languages. Here’s a comprehensive list of commonly used Conda
commands along with examples:

1. Install Conda
Install Miniconda or Anaconda from their respective websites:

Miniconda: https://docs.conda.io/en/latest/miniconda.html

Anaconda: https://www.anaconda.com/products/distribution

2. Basic Information Commands

Command Description Example

`conda --version` Check Conda version `$ conda --version`

`conda info` Display general Conda information `$ conda info`

`conda list` List all installed packages `$ conda list`

3. Working with Environments

🚀 Powered by ChatGPT Exporter 1/7


Command Description Example

`conda create --name Create a new environment `$ conda create --name


ENV_NAME` my_env`

`conda create -n ENV_NAME Create environment with specific `$ conda create -n my_env
PKG_NAME` numpy pandas`
package(s)

`conda env list` List all environments `$ conda env list`

`conda activate ENV_NAME` Activate an environment `$ conda activate my_env`

`conda deactivate` Deactivate the current `$ conda deactivate`

environment

`conda remove --name Remove an environment `$ conda remove --name my_env


ENV_NAME --all` --all`

4. Managing Packages

Command Description Example

`conda install PKG_NAME` Install a package `$ conda install numpy`

`conda install Install a specific package `$ conda install numpy=1.21.0`


PKG_NAME=VERSION`
version

`conda install -c CHANNEL_NAME Install a package from a `$ conda install -c conda-forge


PKG_NAME` matplotlib`
specific channel

`conda update PKG_NAME` Update a package `$ conda update scipy`

`conda update conda` Update Conda `$ conda update conda`

`conda uninstall PKG_NAME` Uninstall a package `$ conda uninstall pandas`

🚀 Powered by ChatGPT Exporter 2/7


5. Cloning an Environment

Command Description Example

`conda create --name NEW_ENV -- Clone an existing `$ conda create --name new_env --
clone OLD_ENV` clone old_env`
environment

6. Exporting and Importing Environments

Command Description Example

`conda env export > Export current environment to a `$ conda env export >
env.yml` my_env.yml`
YAML file

`conda env create -f Create an environment from a YAML `$ conda env create -f
env.yml` my_env.yml`
file

7. Searching for Packages

Command Description Example

`conda search PKG_NAME` Search for a package `$ conda search matplotlib`

🚀 Powered by ChatGPT Exporter 3/7


8. Cleaning Up

Command Description Example

`conda clean --all` Remove unused packages and cache files `$ conda clean --all`

9. Working with Channels

Command Description Example

`conda config --show channels` Show the list of configured `$ conda config --show
channels`
channels

`conda config --add channels Add a new channel `$ conda config --add channels
CHANNEL_NAME` conda-forge`

`conda config --remove channels Remove a channel `$ conda config --remove


CHANNEL_NAME` channels conda-forge`

10. Environment Backup

Create a backup of all environments:

$ conda list --explicit > spec-file.txt

Restore from the backup:

$ conda create --name ENV_NAME --file spec-file.txt

🚀 Powered by ChatGPT Exporter 4/7


Example Workflow

1. Create a new environment and install packages:

conda create --name data_env numpy pandas matplotlib

2. Activate the environment:

conda activate data_env

3. Install additional packages:

conda install seaborn

4. Export the environment:

conda env export > data_env.yml

5. Deactivate and remove the environment:

conda deactivate
conda remove --name data_env --all

This cheat sheet provides all key commands to work efficiently with Conda. Let me
know if you need more details!

To create a Conda environment in the present working directory, follow these


steps:

1. Use the `--prefix` Option

Instead of creating the environment in the default `envs/` folder, use the `--prefix`
option to specify the current directory (`.`):

conda create --prefix ./my_env

🚀 Powered by ChatGPT Exporter 5/7


This will create an environment named `my_env` inside the current working
directory.

2. Activate the Environment

Once created, activate the environment using:

conda activate ./my_env

3. Install Packages in the Local Environment

You can install packages inside this environment as usual:

conda install --prefix ./my_env numpy pandas matplotlib

4. Verify Environment Location

To check if the environment is created in the current directory, run:

conda info --envs

You will see the path instead of just a name, like:

# conda environments:
#

🚀 Powered by ChatGPT Exporter 6/7


base * /home/user/miniconda3
/home/user/project/my_env

5. Removing the Local Environment

To remove the environment, delete the `my_env` directory:

rm -rf my_env

or use:

conda env remove --prefix ./my_env

This method is useful when you want a portable environment inside a project folder.
Let me know if you need more details! 🚀

🚀 Powered by ChatGPT Exporter 7/7

You might also like