Py.test command not found, but library is installed

夙愿已清 提交于 2019-11-29 06:18:31

using python -m pytest will work for you. Or if you using virtual environment and installed pytest on virtualenv you should then run py.test alongside your virtual environment.

Check this website can be useful:http://pythontesting.net/framework/pytest/pytest-introduction/

Ugtar

Are you on a mac with homebrew by any chance?

I had the same issue and it basically came down to permissions/conflict with the mac os base installed python. pip install would not install or link stuff into /usr/local/bin (it happened with both virtualenv and pytest).

  1. I uninstalled python 2.7 completely with homebrew (brew uninstall python).
  2. Next, I reinstalled python with homebrew to fix pip (it was not a symlink in /usr/local/bin/pip where it should have been linked to Cellar) -- brew install python
  3. Then I uninstalled pip with sudo -- sudo python -m pip uninstall pip to remove the pip owned by root
  4. Now I uninstalled and reinstalled python with homebrew again to reinstall pip with the correct permissions brew uninstall python && brew install python
  5. Next I fixed the python symlinks brew link python
  6. Finally, pip install pytest worked! (and so did pip install virtualenv)

I found the information in the chosen answer from this post very helpful: https://superuser.com/questions/915810/pip-not-working-on-hombrew-python-2-7-install.

If you're not on a mac, sorry for the noise...

I already had the latest version of pytest on macOS with Homebrew-installed Python 2.7 and this fixed it:

pip uninstall pytest
pip install pytest

I had the same issue. I had pytest v2.8.3 installed and the binary was on my path but under the name py.test. Upgrading to v3.0.3 added the regular pytest executable to the path.

I Fixed this issue via below steps. 1.First uninstall existing pytest. 2.Check python version. 3.then verify pytest version is supported with python version or not via github issue tracker. 4. via sudo install pytest sudo pip install pytest 5. verify pytest version and insatlled correctly or not. pip list pytest --version

6.run any test using pytest test_abc.py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!