Conda 在 pypi 找不到包。org/simple

Conda can't find packages at pypi.org/simple

我在通过 conda 安装软件包时遇到问题。它在频道 https://pypi.org simple.

中找不到任何包
conda install logbook

returns:

PS C:\WINDOWS\system32> conda config --add channels 
https://pypi.org/simple
Warning: 'https://pypi.org/simple' already in 'channels' list, moving to the top
PS C:\WINDOWS\system32> conda install Logbook
Fetching package metadata ....
WARNING: The remote server could not find the noarch directory for the
requested channel with url: https://pypi.org/simple

It is possible you have given conda an invalid channel. Please double-check
your conda configuration using `conda config --show`.

If the requested url is in fact a valid conda channel, please request that the
channel administrator create `noarch/repodata.json` and associated
`noarch/repodata.json.bz2` files, even if `noarch/repodata.json` is empty.
$ mkdir noarch
$ echo '{}' > noarch/repodata.json
$ bzip2 -k noarch/repodata.json
...........

PackageNotFoundError: Packages missing in current channels:

  - logbook

We have searched for the packages in the following channels:

  - https://pypi.org/simple/win-64
  - https://pypi.org/simple/noarch
  - https://repo.continuum.io/pkgs/main/win-64
  - https://repo.continuum.io/pkgs/main/noarch
  - https://repo.continuum.io/pkgs/free/win-64
  - https://repo.continuum.io/pkgs/free/noarch
  - https://repo.continuum.io/pkgs/r/win-64
  - https://repo.continuum.io/pkgs/r/noarch
  - https://repo.continuum.io/pkgs/pro/win-64
  - https://repo.continuum.io/pkgs/pro/noarch
  - https://repo.continuum.io/pkgs/msys2/win-64
  - https://repo.continuum.io/pkgs/msys2/noarch

我在浏览器中手动检查过,日志模块在第 https://pypi.org/simple 页的列表中。 然而,conda 似乎在 https://pypi.org/simple/win-64 中寻找包,但那里不存在 win-64 目录。

conda config --show 说,配置的通道是 https://pypi.org/simple

add_anaconda_token: True
add_pip_as_python_dependency: True
allow_non_channel_urls: True
allow_softlinks: False
always_copy: False
always_softlink: False
always_yes: False
anaconda_upload: None
auto_update_conda: True
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: True
channels:
  - https://pypi.org/simple
  - https://pypi.org/simple/
  - defaults
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
create_default_packages: []
custom_channels:
  pkgs/main: https://repo.continuum.io/
  pkgs/free: https://repo.continuum.io/
  pkgs/r: https://repo.continuum.io/
  pkgs/pro: https://repo.continuum.io/
  pkgs/msys2: https://repo.continuum.io/
  C:/Program%20Files/Anaconda3/conda-bld: file:///

有什么建议吗?

conda 通道必须具有特定的布局(win-64、win-32 等),并且必须以特定于 conda 的方式构建程序包(请参阅 Building conda packages with conda skeleton)。这些包通常是针对特定 Python 版本构建的(尽管也应该有 noarch 包)and/or numpy 版本和不同平台(windows、linux、mac 32 位或 64 位)。

您不能使用 conda 从 PyPI 直接安装包,因为 PyPI 不符合 conda-channel 的条件,即使它是包,也不会像 conda-packages 那样构建。但是您可以使用 pip(在 conda 中)安装它们。

但是:您可以检查您想要的软件包是否在符合 conda 标准的渠道中分发(目前非常流行的渠道是 conda-forge). At a first glance several channels contain a package named logbook in the anaconda cloud (search results for logbook)。

如果您找到一个分发所需版本包的渠道(并且针对所需的 Python 版本和平台),那么只需使用:

conda install -c channel_name logbook

许多 Python 产品在 Gohlke 页面上 Windows 可用。

假设你在自己的环境中安装了64位的Py3.6,称为Py36,你可以这样做。

Gohlke 下载 Logbook-1.1.0-cp36-cp36m-win_amd64.whl(或您需要的任何版本)。

然后在命令提示符下:

  • activate你要安装Logbook的conda环境
  • 使用 pip 安装您在该环境中下载的 whl
  • 验证成功,如果你愿意的话。

C:\scratch>activate Py36

(Py36) C:\scratch>pip install Logbook-1.1.0-cp36-cp36m-win_amd64.whl
Processing c:\scratch\logbook-1.1.0-cp36-cp36m-win_amd64.whl
Installing collected packages: Logbook
Successfully installed Logbook-1.1.0

(Py36) C:\scratch>conda list
# packages in environment at C:\ProgramData\Miniconda3\envs\Py36:
#
beautifulsoup4            4.6.0                     <pip>
certifi                   2017.11.5        py36hb8ac631_0
chardet                   3.0.4                     <pip>
idna                      2.6                       <pip>
Logbook                   1.1.0                     <pip>
opencv-python             3.4.0+contrib             <pip>
pip                       9.0.1            py36h226ae91_4
python                    3.6.3                h3b118a2_4
requests                  2.18.4                    <pip>
setuptools                36.5.0           py36h65f9e6e_0
urllib3                   1.22                      <pip>
vc                        14                   h2379b0c_2
vs2015_runtime            14.0.25123           hd4c4e62_2
wheel                     0.30.0           py36h6c3ec14_1
wikipedia                 1.4.0                     <pip>
wincertstore              0.2              py36h7fe50ca_0

编辑: 在评论中回复查询。

我输入了这个:

conda env export -n Py36 -f Py36.yml

yaml 文件的内容。

name: Py36
channels:
- defaults
dependencies:
- certifi=2017.11.5=py36hb8ac631_0
- pip=9.0.1=py36h226ae91_4
- python=3.6.3=h3b118a2_4
- setuptools=36.5.0=py36h65f9e6e_0
- vc=14=h2379b0c_2
- vs2015_runtime=14.0.25123=hd4c4e62_2
- wheel=0.30.0=py36h6c3ec14_1
- wincertstore=0.2=py36h7fe50ca_0
- pip:
  - beautifulsoup4==4.6.0
  - chardet==3.0.4
  - idna==2.6
  - logbook==1.1.0
  - opencv-python==3.4.0+contrib
  - requests==2.18.4
  - urllib3==1.22
  - wikipedia==1.4.0
prefix: C:\ProgramData\Miniconda3\envs\Py36