Conda YML file prompts "Please add an explicit pip dependency"

Viewed 2243

I'm trying to install additional libraries for ML.

I'm using a file called tools.yml. Which is built like this

 # conda create --name tensorflow-cpu python=3.8
 # conda install jupyter
 # conda install nb_conda
 # conda install -c anaconda tensorflow
 # conda env update --file tools.yml
dependencies:
    - jupyter
    - scikit-learn
    - scipy
    - pandas
    - pandas-datareader
    - matplotlib
    - pillow
    - tqdm
    - requests
    - h5py
    - pyyaml
    - flask
    - boto3
    - pip:
        - bayesian-optimization
        - gym
        - kaggle
        

But when I run the conda environment update I get this warning

Warning: you have pip-installed dependencies in your environment file, but you do not list pip itself as one of your conda dependencies. Conda may not use the correct pip to install your packages, and they may end up in the wrong place. Please add an explicit pip dependency. I'm adding one for you, but still nagging you.

Which fills the cmd screen. But as far as I'm aware pip is listed a dependency already in the file. Sorry if this seems obvious I'm new.

1 Answers

The line

dependencies:
...
  - pip:  # this line
     ...

is parsed as a list from which to generate a requirements.txt file to then give to pip, but is not considered an explicit directive to install the pip package. To avoid the warning, try:

dependencies:
...
  - pip   # this is a dependency
  - pip:  # this starts a "requirements.txt" list
     ...

It's sort of pedantic, and the code does automatically add a pip as dependency as per the warning, so it's really not consequential. There's likely an Issue on the GitHub repo documenting the genesis of this warning message.

Related