python - 如何安装py.test?

标签 python installation add-on pytest instructions

所以我是 Python 的新手。这可能是一个非常愚蠢的问题,但我不知道如何将软件包安装为 pytest?

如果有人可以给出指示以实现此目的,那就太好了。

最佳答案

一般来说,如果您使用 pip,那么在 Python 中安装一个包非常简单,如果您使用的是 Python 2 >=2.7.9 或 Python 3 >=3.4,它已经安装好了。

为了安装pytest:

Python 2:$ pip install pytest

Python 3:$ pip3 install pytest

但是,通过创建虚拟环境来隔离 Python 环境是一种很好的做法。为了在隔离的虚拟环境中安装 pytest:

python 2

$ pip install -U virtualenv
$ python -m virtualenv venv
$ source venv/bin/activate # in Windows -> $ venv\Scripts\activate.bat
$ pip install pytest

python 3

$ pip3 install -U virtualenv
$ python3 -m virtualenv venv
$ source venv/bin/activate # in Windows -> $ venv\Scripts\activate.bat
$ pip install pytest

Python 3.6+

$ python3 -m venv venv
$ source venv/bin/activate # in Windows -> $ venv\Scripts\activate.bat
$ pip install pytest

关于python - 如何安装py.test?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21150312/

相关文章:

ios - 为什么应用程序在 64 位 5s iPhone 上安装时会卡住

Python __init__ setattr 关于参数?

python - 将对象数据类型列转换为 float 或 int

mysql - 全新的 mysql-server 安装不要求输入密码

ruby-on-rails - 安装 Rails 3 时如何修复 (Errno::EINVAL) 错误?

c# - SAP B1 AddOn,检查表是否存在和创建表的最佳位置是什么?

sql - Redgate SQL Prompt 等效于 PostgreSQL 数据库

python - python 中奇怪的递归行为

python - netbeans 7.1 和 python

google-apps-script - 我可以在 Google Apps 脚本中测试 DocumentProperties 吗?