解决‘Could not find a version that satisfies the requirement pytest‘

最近在学习《Python编程-从入门到实践(第3版)》这本书,学习进行到第11章测试函数时,需要进行安装第三方包'pytest',但是在安装pytest的时候出现了问题,terminal一直返回如下报错:

Could not find a version that satisfies the requirement pytest (from versions: none)

ERROR: No matching distribution found for pytest

在网络上尝试了许多方法,例如: 

  • 对pip进行更新         
  • 更换pip源
  • 使用国内镜像源

看评论区的反馈,上述方法应该可以解决大部分安装失败的问题,但是仍然没有解决我的问题。在查找解决方法时,看到了可以更新python版本再重复上述步骤。我在终端中使用如下命令:

pip show pip

发现pip的安装位置与我的python安装位置不同。

使用如下命令才发现,VSCode的终端一直使用的是之前下载过的python3.7版本。

python --version

进入cmd运行上述命令,也是python3.7版本,于是将环境变量中的python3.11放在最上部,具体步骤可参考下面链接。

【Python】Windows如何在cmd中切换python版本-阿里云开发者社区

将默认python版本改为3.11后,重启VSCode,使用以下命令,完成pytest安装。

首先需要使用如下命令对pip进行更新:

python -m pip install --update pip

之后再使用如下命令进行安装pytest

python -m pip install --user pytest

 如图,成功安装pytest,仅提供一种解决方式,如有错误,欢迎指正。

  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
引用:报错信息"Could not find a version that satisfies the requirement 包名"表示无法找到满足要求的包版本。 引用:解决该问题的方法是更换pip源为国内源,可以尝试使用国内的pip源来解决问题。 引用:然而,有时候即使更换了pip源,还是会出现新的报错信息,如"Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:852)’),)’: /simple/six/ Could not fetch URL https://pypi.org/simple/six/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=‘pypi.org’, port=443): Max retries exceeded with url: /simple/six/ (Caused by SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:852)’),)) - skipping Could not find a version that satisfies the requirement 安装包名字(from versions: ) No matching distribution found for 安装包名字"。 对于问题中的"Could not find a version that satisfies the requirement comm>=0.1.3",你可以尝试以下步骤来解决: 1. 检查包名的拼写是否正确。确保没有输入错误的包名。 2. 如果你使用的是pip,尝试更换国内的pip源。pip源的更换可以参考引用中提到的方法。 3. 如果更换了pip源后仍然遇到问题,可以尝试使用虚拟环境来安装包,以隔离可能的环境冲突。 4. 如果问题仍然存在,可能是由于包的版本问题或者其他依赖关系导致无法找到满足要求的版本。你可以尝试查找其他可用的版本或者查看包的文档和社区来获取更多解决方案。 希望以上建议能够帮助你解决问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Error: Could not find a version that satisfies the requirement](https://blog.csdn.net/m0_62975468/article/details/127960340)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] - *2* *3* [完美解决 Could not find a version that satisfies the requirement 安装包名字 (from versions: )](https://blog.csdn.net/qq_27195727/article/details/128019438)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值