Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

python - I have a problem with pytest execution, I install the pytest but it doesnot show it's version neither it works

C:Userssbhandari>python --version
Python 3.9.1
C:Userssbhandari>pip install pytest


Collecting pytest
  Using cached pytest-6.2.1-py3-none-any.whl (279 kB)
Requirement already satisfied: toml in c:userssbhandariappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39site-packages (from pytest) (0.10.2)
Requirement already satisfied: pluggy<1.0.0a1,>=0.12 in c:userssbhandariappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39site-packages (from pytest) (0.13.1)
Requirement already satisfied: iniconfig in c:userssbhandariappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39site-packages (from pytest) (1.1.1)
Requirement already satisfied: py>=1.8.2 in c:userssbhandariappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39site-packages (from pytest) (1.10.0)
Requirement already satisfied: packaging in c:userssbhandariappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39site-packages (from pytest) (20.8)
Requirement already satisfied: attrs>=19.2.0 in c:userssbhandariappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39site-packages (from pytest) (20.3.0)
Requirement already satisfied: atomicwrites>=1.0; sys_platform == "win32" in c:userssbhandariappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39site-packages (from pytest) (1.4.0)
Requirement already satisfied: colorama; sys_platform == "win32" in c:userssbhandariappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39site-packages (from pytest) (0.4.4)
Requirement already satisfied: pyparsing>=2.0.2 in c:userssbhandariappdatalocalpackagespythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0localcachelocal-packagespython39site-packages (from packaging->pytest) (2.4.7)
Installing collected packages: pytest
  WARNING: The scripts py.test.exe and pytest.exe are installed in 'C:UserssbhandariAppDataLocalPackagesPythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0LocalCachelocal-packagesPython39Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pytest-6.2.1
WARNING: You are using pip version 20.2.3; however, version 20.3.3 is available.
You should consider upgrading via the 'C:UserssbhandariAppDataLocalMicrosoftWindowsAppsPythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0python.exe -m pip install --upgrade pip' command.
C:Userssbhandari>pytest
'pytest' is not recognized as an internal or external command,
operable program or batch file.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

it worked on my computer,i think its not working on your computer because you haven't added it to system variables(PATH),here's how you can do so

pytest and other scripts are mostly present in a directory(in python folder) named 'Scripts'.maybe yours is somewhere else and if so then type pytest.exe in start menu and copy the file location and add it to system variables.if this doesnt work try re-installing pytest or python.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...