ResolvePackageNotFound:在Mac OSX上使用conda和yml文件创建环境

时间:2019-10-26 13:29:20

标签: python pip anaconda yaml conda

最重要的是,我是一个新手,请忍受我的愚蠢:)

我运行此:

conda env create -f env.yml 

这是yml文件:

name: DAND
channels: !!python/tuple
- defaults
dependencies:
- _nb_ext_conf=0.3.0=py27_0
- anaconda-client=1.6.0=py27_0
- appnope=0.1.0=py27_0
- backports=1.0=py27_0
- backports_abc=0.5=py27_0
- beautifulsoup4=4.5.1=py27_0
- clyent=1.2.2=py27_0
- configparser=3.5.0=py27_0
- cycler=0.10.0=py27_0
- decorator=4.0.10=py27_1
- entrypoints=0.2.2=py27_0
- enum34=1.1.6=py27_0
- freetype=2.5.5=1
- functools32=3.2.3.2=py27_0
- get_terminal_size=1.0.0=py27_0
- icu=54.1=0
- ipykernel=4.5.2=py27_0
- ipython=5.1.0=py27_1
- ipython_genutils=0.1.0=py27_0
- ipywidgets=5.2.2=py27_0
- jinja2=2.8=py27_1
- jsonschema=2.5.1=py27_0
- jupyter=1.0.0=py27_3
- jupyter_client=4.4.0=py27_0
- jupyter_console=5.0.0=py27_0
- jupyter_core=4.2.1=py27_0
- libpng=1.6.22=0
- markupsafe=0.23=py27_2
- matplotlib=1.5.3=np111py27_1
- mistune=0.7.3=py27_1
- mkl=11.3.3=0
- nb_anacondacloud=1.2.0=py27_0
- nb_conda=2.0.0=py27_0
- nb_conda_kernels=2.0.0=py27_0
- nbconvert=4.2.0=py27_0
- nbformat=4.2.0=py27_0
- nbpresent=3.0.2=py27_0
- nltk=3.2.1=py27_0
- notebook=4.3.0=py27_0
- numpy=1.11.2=py27_0
- openssl=1.0.2j=0
- pandas=0.19.1=np111py27_0
- path.py=8.2.1=py27_0
- pathlib2=2.1.0=py27_0
- pexpect=4.0.1=py27_0
- pickleshare=0.7.4=py27_0
- pip=9.0.1=py27_1
- prompt_toolkit=1.0.9=py27_0
- ptyprocess=0.5.1=py27_0
- pygments=2.1.3=py27_0
- pymongo=3.3.0=py27_0
- pyparsing=2.1.4=py27_0
- pyqt=5.6.0=py27_1
- python=2.7.12=1
- python-dateutil=2.6.0=py27_0
- python.app=1.2=py27_4
- pytz=2016.10=py27_0
- pyyaml=3.12=py27_0
- pyzmq=16.0.2=py27_0
- qt=5.6.2=0
- qtconsole=4.2.1=py27_1
- readline=6.2=2
- requests=2.12.3=py27_0
- scikit-learn=0.17.1=np111py27_2
- scipy=0.18.1=np111py27_0
- seaborn=0.7.1=py27_0
- setuptools=27.2.0=py27_0
- simplegeneric=0.8.1=py27_1
- singledispatch=3.4.0.3=py27_0
- sip=4.18=py27_0
- six=1.10.0=py27_0
- sqlite=3.13.0=0
- ssl_match_hostname=3.4.0.2=py27_1
- terminado=0.6=py27_0
- tk=8.5.18=0
- tornado=4.4.2=py27_0
- traitlets=4.3.1=py27_0
- unicodecsv=0.14.1=py27_0
- wcwidth=0.1.7=py27_0
- wheel=0.29.0=py27_0
- widgetsnbextension=1.2.6=py27_0
- xlrd=1.0.0=py27_0
- yaml=0.1.6=0
- zlib=1.2.8=3
- pip:
  - backports-abc==0.5
  - backports.shutil-get-terminal-size==1.0.0
  - backports.ssl-match-hostname==3.4.0.2
  - ipython-genutils==0.1.0
  - jupyter-client==4.4.0
  - jupyter-console==5.0.0
  - jupyter-core==4.2.1
  - nb-anacondacloud==1.2.0
  - nb-conda==2.0.0
  - nb-conda-kernels==2.0.0
  - prompt-toolkit==1.0.9
prefix: /Users/mat/anaconda/envs/DAND

我遇到的错误:

Collecting package metadata (repodata.json): done
Solving environment: failed

ResolvePackageNotFound: 
  - jupyter_console==5.0.0=py27_0
  - freetype==2.5.5=1
  - pyzmq==16.0.2=py27_0
  - configparser==3.5.0=py27_0
  - scipy==0.18.1=np111py27_0
  - libpng==1.6.22=0
  - ...then the list goes on and list all of the dependencies in the yml file, except the ones under pip 

我尝试过的事情:

  1. 我从网站上下载的Udacity在线课程中获得了这个yaml文件,因此我认为 conda env export --no-builds> env.yml 方法适用于我。

  2. 我在here中尝试了该解决方案,我只是将所有内容移至pip块下,并遇到新的错误。也许我误解了解决方案。

我遇到的新错误:

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.
Collecting package metadata (repodata.json): done
Solving environment: done
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Ran pip subprocess with arguments:
['/Users/yulia/anaconda3/envs/DAND/bin/python', '-m', 'pip', 'install', '-U', '-r', '/Users/yulia/data analysis -uda/condaenv.mo_ctuap.requirements.txt']
Pip subprocess output:

Pip subprocess error:
ERROR: Double requirement given: backports_abc==0.5=py27_0 (from -r /Users/yulia/data analysis -uda/condaenv.mo_ctuap.requirements.txt (line 12)) (already in backports-abc==0.5 (from -r /Users/yulia/data analysis -uda/condaenv.mo_ctuap.requirements.txt (line 1)), name='backports-abc')

CondaEnvException: Pip failed

我阅读了其他一些建议使用pip来安装requirements.txt文件的文章,以及一些有关“ CondaEnvException:Pip失败”情况的文章。但是他们没有写明确的解决方案,大多数时候我对这些解决方案感到困惑。

请让我知道我在这里缺少什么,这使我感到沮丧,因为我无法设置合适的环境继续上课。提前非常感谢您!

1 个答案:

答案 0 :(得分:0)

更新

当您跳过使用env文件时,似乎最终效果会更好。相反,请手动创建具有所需依赖项的环境,这样可以使库保持最新状态,并且笔记本可以正常工作。

$ conda create -n DAND python=2 numpy pandas matplotlib seaborn

在课程的“设置系统”(或类似内容)部分中查找所需的库。在我的示例中,这些内容基于Udacity的“数据分析入门”课程。


旧答案

我遇到了类似的问题,最终对我有用的是在此YAML文件的通道部分中添加了两个通道。

之前:

channels: !!python/tuple
  - defaults

之后:

channels: !!python/tuple
  - defaults
  - conda-forge
  - anaconda

然后找到所有具有版本限制的软件包。


万一遇到版本冲突的错误,请确保将conda配置channel_priority设置为false

$ conda config --set channel_priority false