哪个软件包使conda降级了软件包?

时间:2018-09-05 11:33:39

标签: python anaconda conda

我正在通过以下命令使用conda安装相当长的软件包列表:

conda install -c conda-forge \
    'nomkl' \
    'ipywidgets=7.4.0' \
    'pandas=0.23.4' \
    'numexpr=2.6.5' \
    'matplotlib=2.2.2' \
    'scipy=1.1.0' \
    'seaborn=0.9.0' \
    'scikit-learn=0.19.1' \
    'scikit-image=0.14.0' \
    'sympy=1.2' \
    'cython=0.28.5' \
    'patsy=0.5.0' \
    'statsmodels=0.8.0' \
    'dill=0.2.8.2' \
    'numba=0.38.1' \
    'bokeh=0.13.0' \
    'sqlalchemy=1.2.10' \
    'hdf5' \
    'libnetcdf' \
    'netcdf4' \
    'h5py=2.8.0' \
    'vincent=0.4.4' \
    'beautifulsoup4=4.6.1' \
    'protobuf=3.6.0' \
    'tensorflow=1.10' \
    'opencv' \
    'keras=2.1' \
    'dask=0.19.0' \
    'dask-glm=0.1.0' \
    'dask-ml=0.9.0' \
    'dask-xgboost=0.1.5' \
    'dask-kubernetes=0.5.0' \
    'msgpack-python' \
    'distributed=1.23' \
    'cloudpickle=0.5.3' \
    'python-blosc' \
    'numpy=1.14.2' \
    'xarray=0.10.8' \
    'gcsfs=0.1.2' \
    'pymc3=3.5' \
    'hdbscan=0.8.15' \
    'pystan=2.17.1.0' \
    'yaafe=0.70' \
    'aubio=0.4.6' \
    'librosa=0.6.2' \
    'nltk=3.2.5' \
    'spacy=2.0.11' \
    'gensim=3.5.0' \
    'textblob=0.15.1' \
    'xlrd=1.1.0'  && \
    conda clean -tipsy

作为副作用,会发生以下降级:

python: 3.6.5-1 conda-forge --> 3.5.5-1

由于我依赖Python 3.6,实际上破坏了我的环境。

检查哪个软件包导致降级的最佳方法是什么?也许有一种方法可以修复Python版本,并使conda在不符合约束的软件包上抛出错误?

1 个答案:

答案 0 :(得分:0)

尝试从环境中运行以下脚本。对我来说,它会将所有内容链接到Python 3.6.6,尽管它在无法使用xgboost时失败。可能与您的环境有所不同。它用Python脚本包装conda create使其与操作系统无关。已在Windows上使用Python 3.6.6进行了测试。

from subprocess import run, PIPE, DEVNULL
import json

deps = ['dask-xgboost=0.1.5', 'nomkl', 'ipywidgets=7.4.0', 'pandas=0.23.4', 'numexpr=2.6.5', 'matplotlib=2.2.2', 'scipy=1.1.0', 'seaborn=0.9.0', 'scikit-learn=0.19.1', 'scikit-image=0.14.0', 'sympy=1.2', 'cython=0.28.5', 'patsy=0.5.0', 'statsmodels=0.8.0', 'dill=0.2.8.2', 'numba=0.38.1', 'bokeh=0.13.0', 'sqlalchemy=1.2.10', 'hdf5', 'libnetcdf', 'netcdf4', 'h5py=2.8.0', 'vincent=0.4.4', 'beautifulsoup4=4.6.1', 'protobuf=3.6.0', 'tensorflow=1.10',     'opencv', 'keras=2.1', 'dask=0.19.0', 'dask-glm=0.1.0', 'dask-ml=0.9.0', 'dask-kubernetes=0.5.0', 'msgpack-python', 'distributed=1.23']

for d in deps:
    links = run('conda create --dry-run --json -n dummy ' + d, stdout=PIPE, stderr=DEVNULL)
    if links.returncode == 0:
        links = json.loads(links.stdout)
        if 'actions' in links:
            links = links['actions']['LINK']
            p = [l for l in links if l['name'] == 'python']
            if len(p): print("{} links python={}".format(d, p[0]['version']))
            else: print("{} - no python".format(d))
        else: print("{} - no actions".format(d))
    else: print("{} failed: {}".format(d, links.stdout.decode('ascii')))

可能更具防御性,但我太懒了,对不起:)