Mac系统conda环境下Poetry无法安装psutil 5.9.4问题咨询
在Mac conda环境中使用Poetry安装psutil 5.9.4失败问题
问题现象
在Mac系统的conda虚拟环境中,使用Poetry工具安装psutil包时,5.9.2和5.9.3版本均可正常完成安装,但尝试安装最新版本5.9.4时失败。
命令执行及报错详情
安装5.9.2版本(成功)
poetry add psutil=="5.9.2"
输出:
Updating dependencies Resolving dependencies... (0.1s) Writing lock file Package operations: 0 installs, 1 update, 0 removals • Updating psutil (5.9.3 -> 5.9.2)
安装5.9.3版本(成功)
poetry add psutil=="5.9.3"
输出:
Updating dependencies Resolving dependencies... (0.1s) Writing lock file Package operations: 0 installs, 1 update, 0 removals • Updating psutil (5.9.2 -> 5.9.3)
安装5.9.4版本(失败)
poetry add psutil=="5.9.4"
报错输出:
Updating dependencies Resolving dependencies... (0.1s) Writing lock file Package operations: 0 installs, 1 update, 0 removals • Updating psutil (5.9.3 -> 5.9.4): Failed RuntimeError Unable to find installation candidates for psutil (5.9.4) at ~/miniconda3/envs/<mycondaenv>/lib/python3.9/site-packages/poetry/installation/chooser.py:103 in choose_for 99│ 100│ links.append(link) 101│ 102│ if not links: → 103│ raise RuntimeError(f"Unable to find installation candidates for {package}") 104│ 105│ # Get the best link 106│ chosen = max(links, key=lambda link: self._sort_key(package, link)) 107│
排查结论
该问题与部分已知的psutil安装问题不同,经详细日志排查,根源在于Poetry校验psutil 5.9.4的安装包时,发现多个包的SHA256校验值与预期不符,包括适配Mac ARM64的psutil-5.9.4-cp38-abi3-macosx_11_0_arm64.whl以及源码包psutil-5.9.4.tar.gz,导致所有适配当前环境的包都被跳过,最终抛出找不到安装候选的错误。
详细日志如下:
• Installing psutil (5.9.4): Pending... [keyring.backend] Loading KWallet [keyring.backend] Loading SecretService [keyring.backend] Loading Windows [keyring.backend] Loading chainer [keyring.backend] Loading libsecret [keyring.backend] Loading macOS Creating new session for pypi.org Skipping psutil-5.9.4-cp36-abi3-win32.whl as sha256 checksum does not match expected value Skipping psutil-5.9.4-cp36-abi3-win_amd64.whl as sha256 checksum does not match expected value Skipping psutil-5.9.4-cp38-abi3-macosx_11_0_arm64.whl as sha256 checksum does not match expected value Skipping psutil-5.9.4.tar.gz as sha256 checksum does not match expected value Skipping wheel psutil-5.9.4-cp27-cp27m-macosx_10_9_x86_64.whl as this is not supported by the current environment Skipping wheel psutil-5.9.4-cp27-cp27m-manylinux2010_i686.whl as this is not supported by the current environment Skipping wheel psutil-5.9.4-cp27-cp27m-manylinux2010_x86_64.whl as this is not supported by the current environment Skipping wheel psutil-5.9.4-cp27-cp27mu-manylinux2010_i686.whl as this is not supported by the current environment Skipping wheel psutil-5.9.4-cp27-cp27mu-manylinux2010_x86_64.whl as this is not supported by the current environment Skipping wheel psutil-5.9.4-cp27-cp27m-win32.whl as this is not supported by the current environment Skipping wheel psutil-5.9.4-cp27-cp27m-win_amd64.whl as this is not supported by the current environment Skipping wheel psutil-5.9.4-cp36-abi3-macosx_10_9_x86_64.whl as this is not supported by the current environment Skipping wheel psutil-5.9.4-cp36-abi3-manylinux_2_12_i686.manylinux2010_i686.manylinux_2_17_i686.manylinux2014_i686.whl as this is not supported by the current environment Skipping wheel psutil-5.9.4-cp36-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl as this is not supported by the current environment . . . RuntimeError Unable to find installation candidates for psutil (5.9.4)
可行解决建议
- 清除Poetry缓存:缓存中的校验值可能过期,执行以下命令清除后重新尝试安装:
poetry cache clear pypi --all - 升级Poetry版本:旧版本Poetry可能存在校验逻辑问题,升级到最新版后重试:
poetry self update - 手动指定安装包:从PyPI下载对应版本的正确whl包,使用本地安装方式:
poetry add ./psutil-5.9.4-cp38-abi3-macosx_11_0_arm64.whl - 临时切换到pip安装:如果上述方法无效,可临时用pip在conda环境中安装,之后再同步到Poetry:
pip install psutil==5.9.4 poetry lock --no-update
内容的提问来源于stack exchange,提问作者tipanverella
相关产品推荐
相关产品推荐

