gpt4 book ai didi

python - 如何修复自定义 conda 包的 conda UnsatisfiableError?

转载 作者:行者123 更新时间:2023-12-03 16:48:53 28 4
gpt4 key购买 nike

我正在尝试打包我的 python 代码以在 Anaconda 云上发布。
文件夹结构如下所示:

.
├── conda-recipe
│   ├── build.bat
│   ├── build.sh
│   └── meta.yaml
├── demos
│   ├── datasets
│   │   ├── com-amazon.all.dedup.cmty.txt
│   │   ├── com-amazon.ungraph.txt
│   │   ├── email-Eu-core-department-labels.txt
│   │   └── email-Eu-core.txt
│   ├── directed_example.ipynb
│   ├── email_eu_core_network_evaluation-Copy1.ipynb
│   ├── node_classification.ipynb
│   └── zacharys_karate_club_evaluation.ipynb
├── LICENSE.txt
├── README.md
├── setup.py
├── sten
│   ├── embedding.py
│   └── __init__.py
├── test
│   ├── __init__.py
│   └── test_system.py
├── zachary_computed.png
└── zachary_expected.png

meta.yaml文件:

package:
name: sten
version: "0.1.0"

source:
path: ..

build:
number: 0
noarch: generic

requirements:
build:
- python >=3.7
- setuptools
run:
- python >=3.7
- pypardiso >=0.2.2
- numpy >=1.18.1
- networkx >=2.4
- scipy >=1.4.1
- markdown


test:
imports:
- sten.embedding

about:
home: https://github.com/monomonedula/simple-graph-embedding
license: Apache License 2.0
license_file: LICENSE.txt
summary: Simple deterministic algorithm for generating graph nodes topological embeddings.

我用来构建包的命令(haasad 是 pypardiso 包的 channel 名称): conda build conda-recipe -c haasad构建成功,我已将其上传到此处:
https://anaconda.org/monomonedula/sten

但是,在使用本地构建安装后,如下所示: conda install sten --use-local -c haasad并将构建上传到云端 conda install -c monomonedula sten -c haasad我遇到了几个问题。
  • 使用 python 3.7 时,我无法导入我的包,即使它列在 conda list 中(我已经仔细检查了所有内容,我使用的是正确的解释器)。
  • 使用 python 3.8 时,我可以导入和使用它,但由于未知原因我无法安装 stellargraph。错误信息:
  • Collecting package metadata (current_repodata.json): done
    Solving environment: failed with initial frozen solve. Retrying with flexible solve.
    Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
    Collecting package metadata (repodata.json): done
    Solving environment: failed with initial frozen solve. Retrying with flexible solve.
    Solving environment: \
    Found conflicts! Looking for incompatible packages.
    This can take several minutes. Press CTRL-C to abort.
    failed

    UnsatisfiableError: The following specifications were found to be incompatible with each other:

    Output in format: Requested package -> Available versions
    conda search sten -c monomonedula --info 的输出:
    sten 0.1.0 py38_0
    -----------------
    file name : sten-0.1.0-py38_0.tar.bz2
    name : sten
    version : 0.1.0
    build : py38_0
    build number: 0
    size : 16 KB
    license : Apache License 2.0
    subdir : noarch
    url : https://conda.anaconda.org/monomonedula/noarch/sten-0.1.0-py38_0.tar.bz2
    md5 : 53661562513861f9433b252c8ae7b5f4
    timestamp : 2020-05-23 19:24:36 UTC
    dependencies:
    - markdown
    - networkx >=2.4
    - numpy >=1.18.1
    - pypardiso >=0.2.2
    - python >=3.7
    - scipy >=1.4.1

    sten 0.1.0 py38_0
    -----------------
    file name : sten-0.1.0-py38_0.tar.bz2
    name : sten
    version : 0.1.0
    build : py38_0
    build number: 0
    size : 16 KB
    license : Apache License 2.0
    subdir : noarch
    url : https://conda.anaconda.org/monomonedula/noarch/sten-0.1.0-py38_0.tar.bz2
    md5 : 53661562513861f9433b252c8ae7b5f4
    timestamp : 2020-05-23 19:24:36 UTC
    dependencies:
    - markdown
    - networkx >=2.4
    - numpy >=1.18.1
    - pypardiso >=0.2.2
    - python >=3.7
    - scipy >=1.4.1
    conda search stellargraph -c stellargraph --info 的输出:
    stellargraph 1.0.0 py_0
    -----------------------
    file name : stellargraph-1.0.0-py_0.tar.bz2
    name : stellargraph
    version : 1.0.0
    build : py_0
    build number: 0
    size : 7.8 MB
    license : Apache Software
    subdir : noarch
    url : https://conda.anaconda.org/stellargraph/noarch/stellargraph-1.0.0-py_0.tar.bz2
    md5 : e62b9c897d0a5481159c1e7cb8024717
    timestamp : 2020-05-05 07:54:44 UTC
    dependencies:
    - gensim >=3.4.0
    - ipykernel
    - ipython
    - matplotlib >=2.2
    - networkx >=2.2
    - numpy >=1.14
    - pandas >=0.24
    - python >=3.6
    - scikit-learn >=0.20
    - scipy >=1.1.0
    - tensorflow >=2.1.0

    The repo

    我在这里缺少什么以及如何正确打包它?

    最佳答案

    问题出在您的 meta.yaml文件。根据 Anaconda blog post :

    Noarch generic packages allow users to distribute docs, datasets, and source code in conda packages





    Noarch Python packages cut down on the overhead of building multiple different pure Python packages on different architectures and Python versions by sorting out platform and Python version-specific differences at install time



    因为要分发纯python包,所以应该使用 noarch: python .此外,您不需要设置 python build 中的版本和 run .我已经包含了一个更新的 meta.yaml以下。它还包含其中的构建脚本,因此您不再需要 build.shbuild.bat文件。它还将许可证部分修复为 conda 将接受的内容(它仍然是 Apache 2.0)。
    package:
    name: sten
    version: "0.1.0"

    source:
    path: ..

    build:
    number: 0
    noarch: python
    script: {{ PYTHON }} setup.py install

    requirements:
    build:
    - python
    - setuptools
    run:
    - python
    - pypardiso >=0.2.2
    - numpy >=1.18.1
    - networkx >=2.4
    - scipy >=1.4.1
    - markdown

    test:
    imports:
    - sten.embedding

    about:
    home: https://github.com/monomonedula/simple-graph-embedding
    license: Apache-2.0
    license_family: Apache
    license_file: LICENSE.txt
    summary: Simple deterministic algorithm for generating graph nodes topological embeddings.

    以下是我使用上述 meta.yaml 构建和安装此软件包的步骤文件:
    git clone https://github.com/monomonedula/simple-graph-embedding
    cd simple-graph-embedding/
    git checkout 'refactor&cleanup'
    # Replace contents of `meta.yaml`
    rm conda-recipe/build.sh conda-recipe/build.bat
    conda create --yes -n testing python=3.7 conda-build conda-verify
    conda activate testing
    conda-build --channel haasad .

    这是我在 3.7 环境中安装软件包时所做的工作。您将找到 sten-0.1.0-py_0.tar.bz2 的完整路径朝下 conda-build日志输出。
    conda install -n testing /home/jakub/miniconda3/envs/testing/conda-bld/noarch/sten-0.1.0-py_0.tar.bz2
    conda activate testing
    $CONDA_PREFIX/bin/python -c "import sten"

    我还在python 3.8环境中测试了安装。
    conda create --yes -n testing3.8 python=3.8
    conda install -n testing3.8 /home/jakub/miniconda3/envs/testing/conda-bld/noarch/sten-0.1.0-py_0.tar.bz2
    conda activate testing3.8
    $CONDA_PREFIX/bin/python -c "import sten"
    conda install --use-local sten对我不起作用——有一个 GitHub issue关于它。

    关于python - 如何修复自定义 conda 包的 conda UnsatisfiableError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61985643/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com