Search code examples
environmentminiconda

Conda: how to add packages to environment from log (not yaml)?


I'm doing an internship (= yes I'm a newbie). My supervisor told me to create a conda environment. She passed me a log file containing many packages.

A quick qwant.com search shows me how to create envs via the

conda env create --file env_file.yaml

The file I was give is however NOT a yaml file it is structured like so:

# packages in environment at /home/supervisors_name/.conda/envs/pancancer:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main
bedtools                  2.29.2               hc088bd4_0    bioconda
blas                      1.0                         mkl
bzip2                     1.0.8                h7b6447c_0

The file contains 41 packages = 44 lines including comments above. For simplicity I'm showing only the first 7.

  1. Appart from adding env name (see 2. below), is there a way to use the file as it is to generate an environment with the packages?

I ran the cmd using

conda env create --file supervisors.log.txt

SpecNotFound: Environment with requirements.txt file needs a name
  1. Where in the file should I put the name?

Solution

  • alright, so, it seems that they give you the output of conda list rather than the .yml file produced by conda with conda env export > myenv.yml. Therefore you have two solutions:

    1. You ask for the proper file and then proceed to install the env with conda built-in pipeline

    2. If you do not have any access on the proper file, you could do one of the following:

      i) Parse with python into a proper .yml file and then do the conda procedure.

      ii) Do a bash script, downloading the packages listed in the file she gave you.

    This is how I would proceed, personally :)