简体   繁体   English

Conda 无法从 conda-forge 中可用的 requirements.txt 安装包,尽管 package 存在于 conda-forge 中

[英]Conda can't install packages from requirements.txt available in conda-forge, although package exists in conda-forge

I added conda-forge to the conda channels:我将 conda-forge 添加到 conda 频道:

$ conda config --show channels
channels:
  - conda-forge
  - defaults

my requirements.txt contains, among others, these lines:我的 requirements.txt 包含以下几行:

ipython-genutils==0.2.0
jupyter-client==6.1.12
jupyterlab-pygments==0.1.2
appnope==0.1.2
jupyterlab-widgets==1.0.0
data==0.4
prometheus-client==0.11.0
latex==0.7.0
scipy==1.5.4
jupyter-core==4.7.1
jupyter-console==6.4.0
async-generator==1.10
vg==1.10.0
sklearn==0.0
postgis==1.0.4

When I try to create a new environment from this requirements.txt using conda with当我尝试使用 conda 从此 requirements.txt 创建一个新环境时

conda create --name myenv --file requirements.txt

I get the following errors:我收到以下错误:

Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - ipython-genutils==0.2.0
  - jupyter-client==6.1.12
  - jupyterlab-pygments==0.1.2
  - appnope==0.1.2
  - jupyterlab-widgets==1.0.0
  - data==0.4
  - prometheus-client==0.11.0
  - latex==0.7.0
  - scipy==1.5.4
  - jupyter-core==4.7.1
  - jupyter-console==6.4.0
  - async-generator==1.10
  - vg==1.10.0
  - sklearn==0.0
  - postgis==1.0.4

Current channels:

  - https://conda.anaconda.org/conda-forge/linux-64
  - https://conda.anaconda.org/conda-forge/noarch
  - https://repo.anaconda.com/pkgs/main/linux-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/linux-64
  - https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

As you can see, conda-forge is listed under "current channels" and ipython-genutils==0.2.0 is available in conda-forge .如您所见,conda-forge 列在“当前频道”下,并且ipython-genutils==0.2.0 在 conda-forge 中可用 However, the package is not found.但是,找不到 package。 How can I fix this problem?我该如何解决这个问题?

I tried both conda config --set channel_priority flexible and ... stable我尝试了conda config --set channel_priority flexible... stable

I run Ubuntu 20.04 LTS, Python 3.10 and Conda 4.12.0我运行 Ubuntu 20.04 LTS、Python 3.10 和 Conda 4.12.0

It looks to me like this should have been a requirements.txt to be used by pip. Note that conda packages can have slightly different names than what is available on pypi.在我看来,这应该是 pip 使用的 requirements.txt。请注意, conda包的名称可能与 pypi 上的名称略有不同。

ipython-genutils is not the correct name, looking at the link you have provided, the name of the package is ipython_genutils with an underscore. ipython-genutils不是正确的名称,查看您提供的链接,package 的名称是带下划线的ipython_genutils The same is true for the other packages that you have written with a hyphen.对于您用连字符编写的其他包也是如此。 They should all be spelled with an underscore.它们都应该用下划线拼写。

That leaves那留下

  - sklearn==0.0
  - latex==0.7.0
  - vg==1.10.0
  - scipy==1.5.4
  - postgis==1.0.4
  - data==0.4
  - appnope==0.1.2

sklearn==0.0 seems to be a corrupt line in your file. sklearn==0.0似乎是您文件中的损坏行。 The package's name is scikit-learn .包的名称是scikit-learn latex , vg and data are not available on conda channels as far as I can tell. latex ,据我所知, vgdata在 conda 频道上不可用。 The same goes for scipy==1.5.4 , only 1.5.3 and 1.6 are available. scipy==1.5.4一样,只有 1.5.3 和 1.6 可用。 postgis only goes back to 2.4.3 on conda-forge, see here , but also seems to be different from what is available on pypi. postgis仅在 conda-forge 上返回到 2.4.3,请参见此处,但似乎也与 pypi 上可用的不同。 appnope is a package only available for macOS, see it's description : appnope是一个仅适用于 macOS 的 package,请参阅它的说明

Simple package for disabling App Nap on macOS >= 10.9, which can be problematic.简单的 package 用于在 macOS >= 10.9 上禁用 App Nap,这可能会有问题。

So with that in mind, we can create a yml file that installs from both conda channels and from pip (Changes to your file: replaced - with _ , removed appnope , added pip dependency, renamed sklearn to scikit-learn and moved it together with latex , scipy , vg , data , postgis to pip requirements. If you are flexible with scipy==1.5.4 , I would advise to change it to scipy==1.5.3 or scipy==1.6.0 and move scipy and sklearn out of the pip installed packages):因此,考虑到这一点,我们可以创建一个从 conda 通道和 pip 安装的 yml 文件(对文件的更改:替换为- ,删除_ ,添加pip依赖appnope ,将 sklearn 重命名为sklearn并将其与scikit-learn一起latexscipy , vg , data , postgispip要求。如果你对scipy==1.5.4很灵活,我建议将其更改为scipy==1.5.3scipy==1.6.0并移动scipysklearn pip安装包):

name: myenv
dependencies:
 - ipython_genutils==0.2.0
 - jupyter_client==6.1.12
 - jupyterlab_pygments==0.1.2
 - jupyterlab_widgets==1.0.0
 - prometheus_client==0.11.0
 - jupyter_core==4.7.1
 - jupyter_console==6.4.0
 - async_generator==1.10
 - pip
 - pip:
   - scikit-learn
   - latex==0.7.0
   - scipy==1.5.4
   - vg==1.10.0
   - data==0.4.0
   - postgis==1.0.4                      

Save this as environment.yml and then do将其保存为environment.yml然后执行

conda env create -f environment.yml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM