Anaconda
Anaconda
Anaconda is a distribution for both Python and R, offering more than just virtual environment management. It includes its own virtual environment system and a unique package management system.
In addition to PyPI, Anaconda supports conda-forge, offering a wide range of scientific computing packages through the conda command. This provides a more advanced dependency check when installing packages. Another alternative of this feature is using pipenv
.
pip
will simply install the package without checking for compatibility issues.
Listing all the environments
conda info --envs
Creating a virtual environment
conda create --name <env_name> python=<version>
conda activate <env_name>
Installing packages
conda install <package_name>
# E.g. conda install progressbar2
# List all the installed packages
conda list
Installing PyPI packages
Using pip
in a conda environment is not recommended. Using it will partially circumventing the conda
dependency checker.
Instead, use the conda
package manager to convert the PyPI package to a conda package.
Converting PyPI packages to Conda packages
# Searches for the package in PyPI and downloads the package
conda skeleton pypi <package_name>
# Builds a conda recipe for the package
conda build <package_name>
# installs the package
conda install --use-local <package_name>
Sharing the environment
Anaconda will include all the dependencies versions, installation channels, environment name, and environment location.
pip freeze
will not include the conda packages.
# Export the environment to a file
conda env export -file environment.yml
# Create an environment from the file
conda env create --name <env_name> -file environment.yml
# Adding to an existing environment
conda env update -file environment.yml