what is the meaning of pip: command in environment .yaml file?

Viewed 76

I am setting up the environment for my project using a .yaml file. I am not very sure about the pip: command meaning in this file.

name: psp_env
channels:
  - conda-forge
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - ca-certificates=2020.4.5.1=hecc5488_0
  - certifi=2020.4.5.1=py36h9f0ad1d_0
  - libedit=3.1.20181209=
  - libffi=3.2.1=
  - libgcc-ng=9.1.0=
  - libstdcxx-ng=9.1.0=
  - ncurses=6.2=
  - ninja=1.10.0=
  - openssl=1.1.1g=
  - pip=20.0.2=py36_3
  - python=3.6.7=
  - python_abi=3.6=1_cp36m
  - readline=7.0=
  - setuptools=46.4.0=py36_0
  - sqlite=3.31.1=
  - tk=8.6.8=
  - wheel=0.34.2=py36_0
  - xz=5.2.5=
  - zlib=1.2.11=
  - pip:
    - scipy==1.4.1
    - matplotlib==3.2.1
    - tqdm==4.46.0
    - numpy==1.18.4
    - opencv-python==4.2.0.34
    - pillow==7.1.2
    - tensorboard==2.2.1
    - torch==1.6.0
    - torchvision==0.4.2
prefix: ~/anaconda3/envs/psp_env

what is the meaning of pip: command? Does it mean install the packages below? What is the difference bewteen the packages above and below pip?

Another question is I think some of these packages are linux/MAC specific (eg.readline). My system is windows. Is it ok for me just remove these packages away from the enviroment file?I have looked through other answers and think it is ok to remove them.

1 Answers

I'm not familiar with this specific YAML configuration file format, but I've seen similar ones before, and the semantics for the dependencies was:

  • by default (i.e., above the pip: block), dependencies are installed by the package manager (conda in your case) -- that's equivalent to running conda install <package> for each of them
  • the pip: block is to declare things that are not to be installed by the package manager, and should be installed using pip instead -- that's equivalent to running poip install <package> for each of them.

There may be a number of reasons to put a package in the pip section, most commonly:

  • it's not available as a conda package, only on as a pip package,
  • the version on conda is not the right one, pip is required to get the right version.
Related