ResolvePackageNotFound: Create env using conda and yml file on MacOS

雨燕双飞 提交于 2019-11-29 11:32:13

问题


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....


回答1:


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



回答2:


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"



回答3:


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.




回答4:


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



来源:https://stackoverflow.com/questions/49154899/resolvepackagenotfound-create-env-using-conda-and-yml-file-on-macos

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!