Using Miniconda
Reason: Anaconda includes most packages, especially for artificial intelligence, but takes up too much space. Miniconda is more lightweight - install only the packages you need. Following the principle of “use only what you need,” I chose to use Miniconda.
Installation
(Skipped…)
Creating Virtual Environments
conda create -n python_3.9 python=3.9
conda create -n env_name python=version
Managing Environments
# Switch to the newly created python_3.9 environment
conda activate python_3.9
# Delete environment (think twice before doing this)
conda remove -n python_3.9 --all
# Exit current environment
conda deactivate
# Return to default environment
conda activate base
Installing Packages
conda install package_name
Using Requirements Files
pip can use requirements files for quick installation and can also generate them. pip usage specifications:
pip freeze > requirements.txt
pip install -r requirements.txt
conda can install from this file:
conda install --yes --file requirements.txt
Exporting and Importing Environments
conda can completely export environments to .yml files:
conda env export > freeze.yml
Then create conda environments directly from exported files:
conda env create -f freeze.yml