Conda安装冲突要求
我正在尝试使用CONDA来创建PIP需求文件的环境。文件的内容为
supports.txt
numpy==1.18.2
torch==1.4.0
torchvision==0.5.0
scikit-learn==0.22.2.post1
Pillow==8.3.2
pydicom==1.4.2
pandas==1.0.3
运行该命令
conda create -n $name --file requirements.txt
给出packagenotfound
错误,因为缺少频道。
我该如何修改这个?
I am attempting to use Conda to create an environment from a Pip requirements file. The contents of the file are
requirements.txt
numpy==1.18.2
torch==1.4.0
torchvision==0.5.0
scikit-learn==0.22.2.post1
Pillow==8.3.2
pydicom==1.4.2
pandas==1.0.3
Running the command
conda create -n $name --file requirements.txt
gives a PackageNotFound
error as the channels are missing.
How do I amend this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可能的问题
存在一些潜在的问题。
conda
pytorch
首先,并非conda中的所有软件包都以与其他存储库相同的名称使用。部分原因是Conda是一个通用软件包存储库的性质,而不是特定于语言的存储库。特别是,
火炬
模块是通过condapytorch
软件包传递的。因此必须改变。
numpy版本不可用,
默认值或 conda-forge 频道似乎都不可用。
为什么会发生这种情况?对于大多数Python包装,Conda都在PYPI存储库的下游工作。当新版本发布时,Conda Forge机器人(例如)将自动生成相应的原料请求。有时,这些不仅仅是“工作”,需要进行一些故障排除才能构建。有时,使构建工作正常工作的过程不会在新版本命中之前完成。这导致了一个较新的拉力请求,将上一个请求取代,并可能导致放弃旧的拉力请求。这会导致Conda Forge的PYPI覆盖范围,并且IS 确切发生了什么在这里。
如果您可以忍受其他版本, conda-forge 确实提供v1.18.1(下图)和v1.18.4(上图)。
否则,如果您需要精确复制软件包版本,则必须从PYPI中源。我最后显示。
频道问题
缺少通道
OP不会指示通道配置。例如,
torchvision == 0.5.0
软件包,仅通过 pytorch 频道可用。蒙版通道
这里的另一个问题可能是使用
channel_priority:strict
设置。如果使用此设置,则可能仅仅是因为SAT求解器排除了所需版本的频道,仅仅是因为软件包(但不正确的版本)可以在较高的优先级频道中提供。如今,channel_priority:flexible
是默认值,可以设置:解决方案
精确复制(仅PYPI)
给出包装名称和版本,这些软件包可能起源于PYPI。如果您需要精确复制原始环境(例如,为了再现科学结果),我建议您从PYPI中采购所有内容。最好的方法是使用conda来源python和pip,然后让pip安装
unignts.txt
。从包装版本来看,我们正在谈论Python 3.7或3.8。只需
python = 3.8
,您可能会很好,但是[精确的猜测来自发布日期将是python = 3.8.2
。因此,尝试类似的内容:emoverument.yaml
创建环境
,然后通过确保
support.txt
在使用YAML的文件夹中。如果稍后将软件包添加到此环境中,我建议仅使用
pip install
。否则, conda可能有问题。/
假设
numpy = 1.18.2
可以替换,只有conda的环境可以替换,仅conda的环境可能是:emoveration.yaml <
strong ,请注意:
请注意: yaml仅使用一个
=
。如果您打算以 ad hoc 方式通过conda安装其他软件包(例如,conda install
),这将是最好的方法。混合的conda-pip环境
您也可以尝试一个与最后一个环境相似的混合环境,但是PIP专门提供
numpy == 1.18.2
。我不建议这样做,因为其他带有Conda的numpy的依赖性肯定会带来Numpy,然后PIP会抓住它以提供确切的版本。Possible Issues
There are a few potential issues.
Conda
pytorch
First, not all packages in Conda go by the same name as they do in other repositories. Part of this is due to the nature of Conda being a general package repository, rather than a language-specific one. In particular, the
torch
module is delivered via the Condapytorch
package.So that has to change.
NumPy version unavailable
That particular build of NumPy does not appear to be available in either defaults or conda-forge channels.
Why would this happen? For most Python packages, Conda works downstream of the PyPI repository. When new releases come out, the Conda Forge bot (for example) will auto-generate a pull request to corresponding feedstock. Sometimes these don't "just work" and need some troubleshooting to get built. Occasionally, the process to get the builds working won't finish before a new release hits. This results in a newer pull request superceding the previous one, and can lead to the old pull request being abandoned. This results in gaps in the coverage of PyPI by Conda Forge, and is exactly what happened here.
If you can tolerate a different version, conda-forge does provide v1.18.1 (below) and v1.18.4 (above).
Otherwise, if you require exact replication of package versions, then you will have to source this from PyPI. I'll show this in the end.
Channel issues
Missing channels
OP does not indicate the channel configuration. The
torchvision==0.5.0
package, for example, only is available through the pytorch channel.Masked channels
Another issue here could be the use of the
channel_priority: strict
setting. If this setting were used, it is possible a channel with the version required might be a priori excluded by the SAT solver simply because the package (but not the correct version) is available in a higher priority channel. These dayschannel_priority: flexible
is the default and can be set with:Solutions
Exact replication (PyPI only)
Give the package names and versions, these packages likely originated from PyPI. If you need to exactly replicate the original environment - say, for reproducing scientific results - then I'd recommend sourcing everything from PyPI. The best way to do this is to use Conda to source Python and Pip, then let Pip install the
requirements.txt
.Judging from the package versions, we're talking Python 3.7 or 3.8. You'd probably be fine with just
python=3.8
, but [a precise guesstimate from release dates would bepython=3.8.2
. So, try something like:environment.yaml
Then create the environment with
making sure the
requirements.txt
is in the folder with the YAML.If adding packages to this environment later, I would recommend only using
pip install
. Otherwise, Conda may have issues.Conda-only environment
Assuming the
numpy=1.18.2
can be substituted, a Conda-only environment might be something like:environment.yaml
Again, creating with:
Note that in YAML only one
=
is used. This would be the best approach if you plan to install additional packages through Conda in an ad hoc manner (e.g.,conda install
).Mixed Conda-Pip environment
You could also try a mixed environment mostly similar to the last one, but having Pip specifically provide
numpy==1.18.2
. I wouldn't recommend this, since the other dependencies with definitely bring in NumPy first from Conda, and then Pip will clobber it to provide the exact version.