'py.test'不被识别为 cmdlet、函数、脚本文件或可操作程序的名称
您好,我正在尝试在 Pycharm 终端中使用“py.test”命令运行我的测试,但每次都会收到此错误消息:
py.test :术语“py.test”未被识别为 cmdlet 的名称,函数、脚本文件或可运行程序。检查名称的拼写,或者如果包含路径,请验证 确认路径正确,然后重试。 在行:1个字符:1
- py.test
+ CategoryInfo : ObjectNotFound: (py.test:String) [], CommandNotFoundException + FullQualifiedErrorId:CommandNotFoundException
Hi I am trying to run my tests using "py.test" command in the Pycharm terminal but every time is am getting this error message:
py.test : The term 'py.test' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At line:1 char:1
- py.test
+ CategoryInfo : ObjectNotFound: (py.test:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
第一个答案:
检查
python -m pytest
或只是pytest
是否适合您。如果是这样 - 也许您已经在不同的环境/全局环境中安装了 pytest。这可能会使 pytest 库在您的环境中不可用/无法访问。如果该命令对您不起作用 - 请确保您已安装 pytest 库:pip install pytest
第二个答案:
尝试更改 Pycharm 内的默认 shell 以使用 CMD(我认为您正在使用 PowerShell?),然后重新启动 pycharm。确保您使用 CMD 作为 pycharm 终端内的默认 shell。
First anwser:
Check if
python -m pytest
or justpytest
works for you. If it does - maybe you have installed pytest in a different env/global env. That can make pytest library unavailable/unreachable in your environment. If the command does not work for you - make sure you have installed pytest library:pip install pytest
Second answer:
Try to change the default shell inside Pycharm to use CMD (I think you are using PowerShell?), then restart pycharm. Make sure you are using CMD as your default shell inside the pycharm terminal.
而 pytest 对我来说不起作用,即使重新安装了 pytest 也是如此。
然后终于
python -m pytest
为我工作了。while
pytest
was not working for me, even after reinstalling pytest.then finally
python -m pytest
worked for me.