Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install packages from yaml file in Conda

I would like to have one YAML file that could serve to both create virtual environments and (most importantly) as a base for installing packages by conda into the global env. I am trying:

conda install --file ENV.yaml

But it is not working since conda expects pip-like format of the requirements. What command should I execute to install packages from my YAML file globally?

like image 316
maciek Avatar asked Oct 07 '19 15:10

maciek


People also ask

How do I install a package in conda?

in terminal, type : conda list to obtain the packages installed using conda. There may be some overlap of these lists as pip may recognize packages installed by conda (but maybe not the other way around, IDK).

Can you use conda to install packages?

Installing packages on a non-networked (air-gapped) computer Conda installs packages into the anaconda/pkgs directory. If conda cannot find the file, try using an absolute path name instead of a relative path name. Installing packages directly from the file does not resolve dependencies.

How do I install a Conda package?

Installing with conda. To install conda packages, in the terminal or an Anaconda Prompt, run: conda install [packagename] During the install process, files are extracted into the specified environment, defaulting to the current environment if none is specified. Installing the files of a conda package into an environment can be thought ...

How do I create a new environment in conda?

The actual environment is created with: conda env create -f base.yml. Later on, additional packages need to be added to base.yml. Another file, say local.yml, needs to import those updates.

How do I use a Python wheel file with conda?

If you have software in a Python wheel file and want to use it with conda or install it in a conda environment, there are 3 ways. The best way is to obtain the source code for the software and build a conda package from the source and not from a wheel. This helps ensure that the new package uses other conda packages to satisfy its dependencies.

How do I create a new meta in yamlfile?

To create a new meta.yamlfile, open your favorite editor. Create a new text file and insert the information shown below. A blank sample meta.yamlfollows the table to make it easier to match up the information. Note To allow correct sorting and comparison, specify versionas a string. name click version


2 Answers

You want the conda-env command instead, specifically

conda env update -n my_env --file ENV.yaml

Read the conda env update --help for details.

If you wish to install this in the base env, then you would use

conda env update -n base --file ENV.yaml

Note that the base env isn't technically "global", but rather just the default env as well as where the conda Python package lives. All envs are isolated unless you are either using the --stack flag during activation to override the isolation or have - contra recommended practice - manually manipulated PATH to include an env.

like image 182
merv Avatar answered Oct 10 '22 16:10

merv


If your conda env is already activated, use:

conda env update --file environment.yml

Or update a specific environment without activating it:

conda env update --name envname --file environment.yml
like image 30
Shady Smaoui Avatar answered Oct 10 '22 17:10

Shady Smaoui