解决方法一:将conda-forge添加到搜索路径上
首先,当出现这种报错时,应该首先尝试使用以下命令将conda-forge channel添加到你的channel列表中:
conda config --append channels conda-forge
它告诉conda在搜索软件包时也要在conda-forge channel上查看。
然后你就可以尝试利用如下命令再次安装
conda install 包名
原因在于:channel可以看成是托管python包的服务器,当无法通过标准channel获得python包时,社区驱动的conda-forge通常是一个很好的地点。大部分问题都可以利用这条语句解决。
方法二:利用报错提示,进入annaconda网站利用命令解决
当添加上述语句仍然出现错误,安装某个python包时(并不特别对于某个特定包,各种包有时都会出现这种情况 。会出现当前channel不可用,并报错:
PackagesNotFoundError: The following packages are not available from current channels:
报错的完整显示:
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- igraph
Current channels:
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/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.
解决办法其实人家在报错中已经说了:
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.
你需要去 https://anaconda.org 这个网址,在上方的搜索条上搜索你要安装这个包的其他channel,下边展示一下如何找igraph的其他channel
首先进入上述网址,你可以在上方看到搜索条:
我这里搜索igraph,会出现所有包名中包含“igraph”字段的包:
接着在你的命令行窗口或Anaconda Prompt窗口对应的路径下运行页面中提供的任意一条命令即可。
方法三:进入annaconda网站利用包的安装包安装
如果上述这些命令经过一一尝试都无效,那只有下载该python包对应的本地“***.bz2”本地文件,然后利用annaconda进行本地安装,需要点击上图的file,下载本机环境下对应的安装包:
把下载好的“python-igraph-0.8.3-py38h0d6bca7_2.tar.bz2”这个安装包放到anaconda存放包的目录下,如:
D/anaconda3/pkgs/~
然后执行命令:
conda install --use-local python-igraph-0.8.3-py38h0d6bca7_2.tar.bz2
即可完成安装。(bz2前的包名根据你所需要的包而不同,“python-igraph-0.8.3-py38h0d6bca7_2.tar.bz2”是我所安装的igraph)