简体   繁体   中英

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 config --show channels
channels:
  - conda-forge
  - defaults

my requirements.txt contains, among others, these lines:

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 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 . However, the package is not found. How can I fix this problem?

I tried both conda config --set channel_priority flexible and ... stable

I run Ubuntu 20.04 LTS, Python 3.10 and 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.

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. 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. The package's name is scikit-learn . latex , vg and data are not available on conda channels as far as I can tell. The same goes for scipy==1.5.4 , only 1.5.3 and 1.6 are available. 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. appnope is a package only available for macOS, see it's description :

Simple package for disabling App Nap on macOS >= 10.9, which can be problematic.

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):

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

conda env create -f environment.yml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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