36

I want to create a virtual environment using conda and yml file.

Command:

conda env create -n ex3 -f env.yml

Type ENTER it gives following message:

ResolvePackageNotFound:

 - gst-plugins-base==1.8.0=0
 - dbus==1.10.20=0
 - opencv3==3.2.0=np111py35_0
 - qt==5.6.2=5
 - libxcb==1.12=1
 - libgcc==5.2.0=0
 - gstreamer==1.8.0=0

However, I do have those on my Mac. My MacOS: High Sierra 10.13.3

My env.yml file looks like this:

name: ex3
channels:
- menpo
- defaults
dependencies:
- cairo=1.14.8=0
- certifi=2016.2.28=py35_0
- cycler=0.10.0=py35_0
- dbus=1.10.20=0
- expat=2.1.0=0
- fontconfig=2.12.1=3
- freetype=2.5.5=2
- glib=2.50.2=1
- gst-plugins-base=1.8.0=0
- gstreamer=1.8.0=0
- harfbuzz=0.9.39=2
- hdf5=1.8.17=2
- icu=54.1=0
- jbig=2.1=0
- jpeg=9b=0
- libffi=3.2.1=1
- libgcc=5.2.0=0
- libgfortran=3.0.0=1
- libiconv=1.14=0
- libpng=1.6.30=1
- libtiff=4.0.6=3
- libxcb=1.12=1
- libxml2=2.9.4=0
- matplotlib=2.0.2=np111py35_0
- mkl=2017.0.3=0
- numpy=1.11.3=py35_0
- openssl=1.0.2l=0
- pandas=0.20.1=np111py35_0
- patsy=0.4.1=py35_0
- pcre=8.39=1
- pip=9.0.1=py35_1
- pixman=0.34.0=0
- pyparsing=2.2.0=py35_0
- pyqt=5.6.0=py35_2
- python=3.5.4=0
- python-dateutil=2.6.1=py35_0
- pytz=2017.2=py35_0
- qt=5.6.2=5
- readline=6.2=2
- scipy=0.19.0=np111py35_0
- seaborn=0.8=py35_0
- setuptools=36.4.0=py35_1
- sip=4.18=py35_0
- six=1.10.0=py35_0
- sqlite=3.13.0=0
- statsmodels=0.8.0=np111py35_0
- tk=8.5.18=0
- wheel=0.29.0=py35_0
- xz=5.2.3=0
- zlib=1.2.11=0
- opencv3=3.2.0=np111py35_0
- pip:
  - bleach==1.5.0
  - enum34==1.1.6
  - html5lib==0.9999999
  - markdown==2.6.11
  - protobuf==3.5.1
  - tensorflow==1.4.1
  - tensorflow-tensorboard==0.4.0
  - werkzeug==0.14.1

How to solve this problem?

Well....The stack overflow prompt me to say more details, but I think I describe things clearly, it is sad, stack overflow does not support to upload attachment....

waschbaerYOYO
  • 481
  • 1
  • 4
  • 8

7 Answers7

65

I had same problem and found your question googling for it.

ResolvePackageNotFound error describes all packages not installed yet, but required.

To solve the problem, move them under pip section:

name: ex3
channels:
- menpo
- defaults
dependencies:
  - cairo=1.14.8=0
  - ***
  - another dependencies, except not found ones
  - pip:
    - gst-plugins-base==1.8.0                
    - bleach==1.5.0
    - enum34==1.1.6
    - html5lib==0.9999999
    - markdown==2.6.11
    - protobuf==3.5.1
    - tensorflow==1.4.1
    - tensorflow-tensorboard==0.4.0
    - werkzeug==0.14.1
    *** added ***
    - gst-plugins-base==1.8.0
    - dbus==1.10.20
    - opencv3==3.2.0
    - qt==5.6.2
    - libxcb==1.12
    - libgcc==5.2.0
    - gstreamer==1.8.0
John
  • 925
  • 9
  • 16
Northern Poet
  • 1,529
  • 9
  • 15
  • 16
    I had the same issue, between two Ubuntu machines, so the suggestion of the OP that it could be related to different OSes does not seems to hold. Your solution worked for me, but it is a bit of a shame to encounter dependency hell by using the system supposed to save us from it ;) – LCT Sep 20 '18 at 22:17
  • Thank you. Solved it for me. – Eric Fulmer Oct 19 '18 at 13:13
  • 1
    This worked for me too. Should mark this as an answer. – xiaoshir Feb 28 '19 at 07:35
  • @LCT I've had the same problem with two Ubuntu machines as well. I also agree that I don't think it's a matter of two different OS'. My *guess* (and it would be great if someone can chime in here) is that some packages have been moved or have been deleted. That is the difference between the two Ubuntu machines in my case -- a lot of time has passed. About a year, I would say. Somehow, I thought conda packages would "stay forever", but I guess I'm wrong? – Ray Aug 16 '19 at 16:47
  • 2
    it really depends on where your repo is available. for my dependency i solved the issue by putting in `- conda-forge` as a channel under defaults. – user108569 Sep 24 '19 at 18:18
  • None of the solutions helped me, does anyone have any other options? – MJimitater Dec 11 '20 at 10:48
  • If anyone is getting an error when conda tries to parse the newly altered file, it's worth noting that there needs to be TWO spaces indent for the pip subsection (as shown). I don't know why this is because I have a one space indent for the outer dependencies section and that works fine. – otocan Apr 13 '21 at 09:35
4

I got the same issue and found a GitHub issue related to this. In the comments, @kalefranz posted an ideal solution by using the --no-builds flag with conda env export.

conda env export --no-builds > environment.yml

However, even remove build numbers, some packages may still have different version number at different OS. The best way I think is to create different env yml file for different OS.

Hope this helps.

Shixiang Wang
  • 1,030
  • 2
  • 12
  • 22
1

There can be another reason for the 'ResolvePackageNotFound' error -- the version of the packages you require might be in an old version of the repository that is not searched by default.

The different paths to locations in the Anaconda repositories can be found at:
https://repo.continuum.io/pkgs/

My yml file [NW_BI.yml] is as follows:

name: NW_BI
channels:
- 'https://repo.continuum.io/pkgs/free' # Remove this line and it fails!!!
- conda-forge
- defaults
dependencies:
- python=2.7.10
- pandas=0.16.2
- pyodbc=3.0.10

Create using:

conda env create -f 'path to file'\NW_BI.yml

I wanted to recreate an old environment!!!!

Note using:
Anaconda3 2019.10
Windows10

1

tl;dr conda env export --from-history -n name_of_your_env -f environment.yml


conda env export command pins your dependencies to the exact version along with OS specific details.

Looks like this for Pandas on macOS for example, - pandas=1.0.5=py38h959d312_0. conda env create cannot use this to create the same environment on other OS, like Linux inside Docker for instance.

So export the packages without pinning, and the ones you specifically installed after creating the conda environment, from history, using conda env export --from-history.

https://repo2docker.readthedocs.io/en/latest/howto/export_environment.html

Dhruv Nagarajan
  • 168
  • 2
  • 14
0

If you are looking at this and feel too much chore to change Conda version packge=ver=py.* to pip style package==ver, I wrote this small script that delete the =py.* part from Conda style.

Note below code work on the presume that you already changed package=ver to package==ver.

#!/bin/bash

COUNT=0
find_pip=0

while IFS= read -r line; do
    COUNT=$(( $COUNT + 1 ))
#    echo "$COUNT"
#    echo "read it"
    if echo ${line} | grep -q -- "- pip:" ; then
#        echo "find it"
        find_pip=1
        indent=`awk -F- '{print length($1)}' <<< "$line"`
        pip_indent=$(( $indent + 2 ))
#        echo $indent
#    echo $pip_indent
    fi

    line_indent=`awk -F- '{print length($1)}' <<< "$line"`

    if [[ ${find_pip} ]] && [[ ${pip_indent} -eq ${line_indent} ]]; then
#        echo "$line"
        new_line=`echo ${line} | cut -d'=' -f-3`
        new_line="    $new_line"
#        echo "${new_line}"
        sed -e "${COUNT}s/.*/${new_line}/" -i '' $1
    fi
done < "$1"
0

I had a similar issue and was able to work around it. My issue wasn't related to pip but rather because the export platform wasn't the same as the import platform (Ref: nehaljwani's November 2018 answer on https://github.com/conda/conda/issues/7311).

@Shixiang Wang's answer point towards a part of the solution. The no-build argument allows for more flexibility but there are some components which are specific to the platform or OS.

Using the no-build export, I was able to identify (from the error message at import time) which libraries were problematic and simply removed them from the YML file. This may not be flawless, but saves a lot of time compared to starting from scratch.

NOTE: I got a Pip subprocess error which interrupted the installation at a given library, which could be simply overcome via a conda install <library>. From there I could relaunch the import from the YML file.

ml_chai
  • 11
  • 3
0

Use --no-builds option to conda env export

https://github.com/conda/conda/issues/7311#issuecomment-442320274

Andrei Margeloiu
  • 580
  • 1
  • 9
  • 16