简体   繁体   English

'py.test' 不是内部或外部命令,也不是可运行的程序或批处理文件

[英]'py.test' is not recognized as an internal or external command, operable program or batch file

I started learning python recently and I know my problem may not be sth complicated.我最近开始学习python,我知道我的问题可能并不复杂。 I issued below command from my Windows cmd to install pytest framework and its required dependencies我从我的 Windows cmd 发出以下命令来安装 pytest 框架及其所需的依赖项

py -3 -m pip install pytest

and then issued: py -3 -m pip install pytest-pep8然后发出: py -3 -m pip install pytest-pep8

to install pep8 plug-in and required dependencies.安装 pep8 插件和所需的依赖项。 Both commands were done successfully.两个命令都成功完成。

But when I want to run pytest by py.test --pep8 exp1.py command;但是当我想通过py.test --pep8 exp1.py命令运行 pytest 时; I get mentioned error.我得到提到的错误。

any ideas?有任何想法吗?

i am learning python with head first python book, i have been trying to use pytest module but was, not working and even search online everywhere but i could not find the solution the problem but some how, i manage to figure it out.我正在用第一本 python 书学习 python,我一直在尝试使用 pytest 模块,但是,没有工作,甚至到处都在网上搜索,但我找不到问题的解决方案,但我设法弄清楚了。 so here's the solution the current version of pytest is version 6.2.2 unfortunately if use it with py.test --pep8 it will not work because it has been deprecated the simple solution is to use this version pip install pytest==2.9.1 and when it's successfully installed when you tried with the py.test --pep8 it will work.所以这是解决方案 pytest 的当前版本是 6.2.2 不幸的是,如果将它与py.test --pep8一起使用, py.test --pep8 ,因为它已被弃用,简单的解决方案是使用此版本pip install pytest==2.9.1当您尝试使用py.test --pep8成功安装它时,它将起作用。

The error you got seems to be due to improper installation of pytest or due to use of py.test in your command.您得到的错误似乎是由于 pytest 安装不当或由于在您的命令中使用了py.test

First, check whether you have pytest installed in your environment.首先,检查您的环境中是否安装了 pytest。 Open command prompt and use the below command,打开命令提示符并使用以下命令,

pytest --version 

You must get an output like,你必须得到这样的输出,

pytest 6.0.2

If you get an output similar to the above result that means you have installed pytest successfully.如果您得到与上述结果类似的输出,则表示您已成功安装 pytest。

Now, navigate to the folder where your script exp1.py is using cd command in cmd and try running your script as follows,现在,导航到您的脚本exp1.py在 cmd 中使用cd命令的文件夹,并尝试按如下方式运行您的脚本,

pytest --pep8 exp1.py

遇到同样的问题,但已通过以下命令解决

python -m pytest

to run pytest along with geting output status in terminal run this in terminal:要在终端中运行 pytest 并获取输出状态,请在终端中运行它:

pytest -v -s filename.py

if the file is not present, run this in the current directory:如果文件不存在,请在当前目录中运行:

pytest -v -s <filepath>/filename.py

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 py 未被识别为内部或外部可运行程序或批处理文件 - py is not recognized as an internal or external operable program or batch file 如何修复“py”未被识别为内部或外部命令、可运行程序或批处理文件 - How to fix 'py' is not recognized as an internal or external command, operable program or batch file 无法将pycrypto&#39;chmod&#39;的setup.py install运行为内部或外部命令,可操作程序或批处理文件 - Running setup.py install for pycrypto 'chmod' is not recognized as an internal or external command, operable program or batch file 如何解决错误“&#39;py.exe&#39;不被识别为内部或外部命令,可操作程序或批处理文件”的错误? - How to fix error “'py.exe' is not recognized as an internal or external command, operable program or batch file”? 如何修复“auto-py-to-exe”不被识别为内部或外部命令、可运行程序或批处理文件 - how to fix 'auto-py-to-exe' is not recognized as an internal or external command, operable program or batch file &#39;pip3&#39; 不是内部或外部命令,也不是可运行的程序或批处理文件 - 'pip3' is not recognized as an internal or external command, operable program or batch file &#39;pip&#39;不被识别为内部或外部命令,可操作程序或批处理文件 - 'pip' is not recognized as an internal or external command, operable program or batch file 不是内部或外部命令、可运行的程序或批处理文件 - is not recognized as an internal or external command, operable program or batch file &#39;{&#39;不被识别为内部或外部命令,可操作程序或批处理文件 - '{' is not recognized as an internal or external command, operable program or batch file &#39;。&#39; 不被识别为内部或外部命令、可运行程序或批处理文件。 什么是 &#39;。&#39;? - '.' is not recognized as an internal or external command, operable program or batch file. What is '.'?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM