Pytest 无法升级到 MacOS Sierra

Pytest not working with upgrade to MacOS Sierra

我最近将我的 Mac 从 Mac OSX El Capitan 升级到 macOS Sierra (10.12.1)。 pytest (link) 在以前版本的 El Capitan 中工作得很好,但现在它在版本检查时抛出以下错误:

$ python3 pytest --version
/Library/Frameworks/Python.framework/Versions/3.5/Resources/Python.app/Contents/MacOS/Python: can't open file 'pytest': [Errno 2] No such file or directory

我认为 pytest 可能在升级过程中迷路了。所以,我再次尝试安装它:

$ pip3 install -U pytest     
Requirement already up-to-date: pytest in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Requirement already up-to-date: py>=1.4.29 in /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages (from pytest)

哎呀,我什至删除了它并重新安装了它(通过 pip3)。不行。

现在,我再也不必为 python 模块添加路径到我的 .bash_profile(或者在我的情况下,我的 .zshrc)。需要明确的是,Python 已将我的 .zprofile 更新为

# Setting PATH for Python 3.5
# The original version is saved in .zprofile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH

为了完整性,

$ which python3
/usr/local/bin/python3

$ echo $SHELL
/bin/zsh

echo $PATH
[...clipped...]:/usr/local/bin:[...clipped...]

我在这里不知所措。如果 .zprofile 有正确的包路径,为什么 pytest 不起作用?有谁知道如何让 pytest 使用 macOS Sierra?

注意:我查看了 Google 和 SO,但找不到有帮助的问题。

编辑:

我忘了在原文 post 中提到该标准不起作用,因为我使用了两个版本的 python

$ pytest --version 
zsh: command not found: pytest

当然可以。在我发布问题后不久,我记得 pytest 需要使用 -m 标志(通过 python3)为 modules 调用:

$ python3 -m pytest --version 
This is pytest version 3.0.5, imported from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/pytest.py