17

After I run the conda env create -f environment.yml in Conda, I receive the following warning:

Warning : you have pip-installed dependencies in your environment file, but you do not list pip itself as one of your conda dependencies...

What does this mean and what should I be doing instead?

merv
  • 67,214
  • 13
  • 180
  • 245
QMarkLi
  • 203
  • 1
  • 2
  • 5

2 Answers2

22

When creating an environment the warning disappeared by including - pip explicitly in the yaml file. Yes, it is a bit awkward because if your environment has pip packages you already have declared that you used pip packages with - pip:
The yaml file would look like:

# Packages omitted for simplicity
name: myenv
channels:
  - anaconda
  - conda-forge
  - defaults
dependencies:
  - python
  - scipy
  - pip
  - pip:
    - datetime

At the time of creating a new environment from scratch this warming can be avoided by explicitly installing pip, for instance with: conda create -n env_with_pip python=3.7 numpy pip

eliasmaxil
  • 530
  • 4
  • 13
  • 4
    I'd like to mention that this "warning" is actually not a warning, since it will be printed indefinitely without another action, but an error. But as described, just adding the pip before solves the issue. Thank you :) – themenace Oct 02 '21 at 08:29
21

In your environment yml file under list of the packages you install through conda you must also add pip as a package to be installed. This installs the pip, and so your pip packages can be installed using this pip.

Previously pip was shipped with conda but now we have to explicitly install pip when using conda

Ali_Sh
  • 2,667
  • 3
  • 43
  • 66
ArunJose
  • 1,999
  • 1
  • 10
  • 33
  • 2
    Thank you very much! I add pip in the environment.yml file under the dependencies then it works. – QMarkLi Oct 25 '19 at 08:12
  • 1
    Which version of pip should I install? There are so many errors in the next step after I add pip==19.3.1 in dependencies. – QMarkLi Oct 27 '19 at 08:38
  • 1
    What are the errors? 19.3.1 should be fine if you are working with latest packages. But if you are using some deprecated packages you should be using older versions of pip. You can post a new question with your yml file and errors – ArunJose Oct 28 '19 at 02:37
  • The error shows the version of "cloudpickle" is wrong. I will post a new question, thank you! – QMarkLi Oct 29 '19 at 01:38
  • could you give an example `environment.yml` file that highlights this please – baxx Apr 10 '20 at 17:25
  • found an example here: https://github.com/conda/conda/blob/54e4a91d0da4d659a67e3097040764d3a2f6aa16/tests/conda_env/support/advanced-pip/environment.yml – Higgs Jul 18 '21 at 11:47