anaconda遇到:Solving environment: failed with initial frozen solve. Retrying with flexible solve.问题
第一种情况:
有时遇到找不到文件夹等的问题:
conda clean --all # 清理缓存后,应该就可以了。
所有安装包的缓存都被清理,也可以只清理特定的。
conda clean --packages --tarballs #清除已经安装但没有安装完全的包
第二种情况:
或者:
1.找到下图中,具体报错所在的文件。(蓝色笔记标出的)
2.找到并删除这个文件
3.重新在交互框中安装原先的。
安装成功至100%,再按个回车,然后再结束
4.关闭交互框,重新开启一个,以验证是否安装成功。首先输入“python”,启动 Python 解释器。输入“import torch”(按你原来的),没有报错即安装成功。也可以输入一些简单的代码,如查看版“cv2.__version__”(前后都是两个下划线)
再找问题的时候,还遇到其他的解决办法,比如“conda clean”的,但我反正没解决。
第三种情况:
python 安装环境时出现报错:
CondaVerificationError: The package for tk located at /home/anaconda3/pkgs/tk-8.6.12-h1ccaba5_0 appears to be corrupted. The path 'include/itclInt.h' specified in the package manifest cannot be found.
The following NEW packages will be INSTALLED: cycler pkgs/main/win-64::cycler-0.10.0-py38_0 freetype pkgs/main/win-64::freetype-2.10.4-hd328e21_0 icu pkgs/main/win-64::icu-58.2-ha925a31_3 jpeg pkgs/main/win-64::jpeg-9b-hb83a4c4_2 kiwisolver pkgs/main/win-64::kiwisolver-1.3.1-py38hd77b12b_0 libpng pkgs/main/win-64::libpng-1.6.37-h2a8f88b_0 libtiff pkgs/main/win-64::libtiff-4.2.0-hd0e1b90_0 lz4-c pkgs/main/win-64::lz4-c-1.9.3-h2bbff1b_0 matplotlib pkgs/main/win-64::matplotlib-3.3.4-py38haa95532_0 matplotlib-base pkgs/main/win-64::matplotlib-base-3.3.4-py38h49ac443_0 multitasking ranaroussi/noarch::multitasking-0.0.9-py_0 olefile pkgs/main/noarch::olefile-0.46-py_0 pillow pkgs/main/win-64::pillow-8.2.0-py38h4fa10fc_0 pyqt pkgs/main/win-64::pyqt-5.9.2-py38ha925a31_4 qt pkgs/main/win-64::qt-5.9.7-vc14h73c81de_0 quantstats ranaroussi/noarch::quantstats-0.0.25-py_0 seaborn pkgs/main/noarch::seaborn-0.11.1-pyhd3eb1b0_0 sip pkgs/main/win-64::sip-4.19.13-py38ha925a31_0 tabulate pkgs/main/win-64::tabulate-0.8.9-py38haa95532_0 tk pkgs/main/win-64::tk-8.6.10-he774522_0 xz pkgs/main/win-64::xz-5.2.5-h62dcd97_0 yfinance ranaroussi/noarch::yfinance-0.1.54-py_0 zstd pkgs/main/win-64::zstd-1.4.9-h19a0ad4_0 Proceed ([y]/n)? y Preparing transaction: done Verifying transaction: failed CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'python-scripts/sample' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance-0.1.54.dist-info/INSTALLER' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance-0.1.54.dist-info/METADATA' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance-0.1.54.dist-info/RECORD' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance-0.1.54.dist-info/WHEEL' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance/__init__.py' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance/base.py' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance/multi.py' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance/shared.py' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance/ticker.py' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance/tickers.py' specified in the package manifest cannot be found. CondaVerificationError: The package for yfinance located at C:\Users\Latitude User\anaconda3\pkgs\yfinance-0.1.54-py_0 appears to be corrupted. The path 'site-packages/yfinance/utils.py' specified in the package manifest cannot be found.
这样的报错,头一回见,直接给我整不会了。思考了一下报错原因,唯一做的事情就是在安装环境时,又同时在安装其他的库,所以我想其他的库和未安装完成的库之间可能出现了冲突导致的。
解决方法,如下所示:
conda clean --packages --tarballs
然后,再重新安装环境,就不会出现报错了。
这行代码是用于清理conda环境中的软件包和已下载的tarball文件。具体而言:
- `conda`: 这是 Conda 软件包管理器的命令行工具。
- `clean`: 这是一个 Conda 命令,用于执行清理操作。
- `--packages`: 这个选项告诉 Conda 清理掉已经下载并安装的软件包,但不清理已安装的包。
- `--tarballs`: 这个选项告诉 Conda 清理已下载但未安装的 tarball 文件,这些文件通常是 Conda 用于安装软件包时临时下载的压缩文件。
因此,整个命令的意思是清理掉环境中已经下载的软件包和 tarball 文件,以释放磁盘空间并减少不必要的文件。
第四种情况:
准备新建一个env的时候,conda报:
CondaVerificationError: The package for wheel located at /home/yu/anaconda3/pkgs/wheel-0.36.2-pyhd3eb1b0_0 appears to be corrupted. The path 'site-packages/wheel/vendored/__init__.py' specified in the package manifest cannot be found. CondaVerificationError: The package for wheel located at /home/yu/anaconda3/pkgs/wheel-0.36.2-pyhd3eb1b0_0 appears to be corrupted. The path 'site-packages/wheel/vendored/packaging/__init__.py' specified in the package manifest cannot be found.
解决方法也很简单,按照这里网友的建议:https://blog.csdn.net/qq_35240640/article/details/114039835
把anaconda3/pkgs/下对应的包删掉就可以了。
而运行:conda clean --packages --tarballs 或者 conda clean --all 是没有用的。
另外,吐槽一下,之所以要新建env的原因是,想装一下PyTorch Geometric (PyG),我之前写GNNs主要用的是DGL,一直没用过的Geometric。按照这里:https://github.com/rusty1s/pytorch_geometric
如果直接运行:
conda install pytorch-geometric -c rusty1s -c conda-forge
发现会把现有的Pytorch替换掉,才想起来可能自己的pytorch版本比较老吧:
The following packages will be UPDATED: ca-certificates pkgs/main::ca-certificates-2021.5.25-~ --> conda-forge::ca-certificates-2021.5.30-ha878542_0 mkl 2020.1-217 --> 2020.2-256 pytorch pytorch::pytorch-1.6.0-py3.7_cuda10.2~ --> pkgs/main::pytorch-1.8.1-cpu_py37h60491be_0
这个……,你要替换我也能理解,为啥换成CPU版本的呢。所以没办法,才准备再新建一个env了。
其他情况:
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
遇到上述问题:
解决方案:
# 更新conda conda update -n base conda conda update -all # 修改频道 conda config --add channels conda-forge conda config --set channel_priority flexible # 安装成功!
我了解conda-forge是为了建立和维护软件包而发起的。
但是,当构建Anaconda Python环境时,如果两个存储库中都存在包,我们如何知道何时使用'conda-forge'还是'conda install'?例如,Django可以安装'conda install'和'conda-forge'。
我们应该使用哪一个?有关系吗?
因此conda-forge
是可以安装软件包的附加渠道。从这个意义上说,它不是比默认频道或其他数百(数千个)频道中人们发布套餐所特有的更特别的。如果在https://anaconda.org注册并上传自己的Conda软件包,可以添加自己的频道。
有两种方法可以更改频道的选项。一种是每次安装包时指定一个频道:
conda install -c some-channel packagename
当然,该套件必须存在于该频道上。如果经常使用相同的频道,那么可能需要将其添加到配置中。你可以写
conda config --add channels some-channel
将通道添加some-channel
到channels
配置列表的顶部。这给出some-channel
了最高优先级(当多个通道具有特定包时,优先级(部分地)确定选择哪个通道)。要将频道添加到列表的末尾并为其指定最低优先级,请键入
conda config --append channels some-channel
如果您想要删除添加的频道,可以通过书写来完成
conda config --remove channels some-channel
看到
conda config -h
获得更多选择。
综上所述,使用该conda-forge
频道取代defaults
Continuum维护的频道有三个主要原因:
conda-forge
可能比defaults
频道更新conda-forge
频道上有不可用的软件包defaults
- 更愿意使用依赖项,如
openblas
(fromconda-forge
)而不是mkl
(fromdefaults
)。