已安装 pytest 但在 bash 中运行 `pytest` 返回 `not found`

Han*_*nel 8 python django pytest vagrant pytest-django

我正在关注Vagrant (Ubuntu 18.04 / Python3.6.6) 中的python-django教程。运行pip3 install pytest-django配置pytest.ini文件后,运行pytest返回

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

apt install python-pytest
Please ask your administrator.
Run Code Online (Sandbox Code Playgroud)

pip3 freeze 输出:

pytest==3.10.0
pytest-django==3.4.3
Run Code Online (Sandbox Code Playgroud)

安装还有其他东西吗?

Cor*_*zin 12

试试 python -m pytest

通过 pip 安装 pytest 不会使其成为系统命令,而是将其安装到 python。-m 命令将 pytest 作为它自己的命令运行,然后任何正在进行的脚本都将是一个参数。