[英]'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.