Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installed pytest but running `pytest` in bash returns `not found`

I am following the python-django tutorial in Vagrant (Ubuntu 18.04 / Python3.6.6). After running pip3 install pytest-django and configuring pytest.ini file, running pytest returns

Command 'pytest' not found, but can be installed with:

apt install python-pytest
Please ask your administrator.

pip3 freeze output:

pytest==3.10.0
pytest-django==3.4.3

Is there something else to the installation?

like image 776
Hank McDonnel Avatar asked Nov 05 '18 12:11

Hank McDonnel


People also ask

Why pytest is not recognized?

Not having the pytest package installed by running pip install pytest . Installing the package in a different Python version than the one you're using. Installing the package globally and not in your virtual environment. Your IDE running an incorrect version of Python.

How do I enable pytest?

To ensure all pytest-specific features are available, set the test runner manually: press Ctrl+Alt+S to open the IDE settings and select Tools | Python Integrated Tools, and then select pytest from the Default test runner list.


1 Answers

Try python -m pytest

Installing pytest via pip doesn't make it a system command, it installs it to python. The -m command runs pytest as its own command and then any proceeding script will be an argument.

like image 145
Cory Nezin Avatar answered Sep 28 '22 06:09

Cory Nezin