E. *_*ero 14 terminal command pip pytest
关于此主题的堆栈溢出已经有两个帖子; 但是,他们都没有解决或解决我的具体情况.
我已经安装了pytest via pip install pytest.我也能用Python导入库.
问题是,当我尝试py.test在终端中使用该命令时,我得到了py.test: command not found.
有没有人知道为什么我无法在终端中使用该命令?
编辑:它甚至显示为已安装的包:
$ pip list
cycler (0.9.0)
matplotlib (1.5.1)
numpy (1.10.1)
pip (8.1.0)
py (1.4.31)
pyparsing (2.0.7)
pytest (2.9.0)
python-dateutil (2.4.2)
pytz (2015.7)
scipy (0.17.0)
setuptools (7.0)
six (1.10.0)
tensorflow (0.5.0)
vboxapi (1.0)
wheel (0.26.0)
Run Code Online (Sandbox Code Playgroud)
Ehs*_*ani 30
使用python -m pytest将适合你.或者,如果您使用虚拟环境并在virtualenv上安装了pytest,那么您应该在虚拟环境中运行py.test.
检查这个网站是有用的:http://pythontesting.net/framework/pytest/pytest-introduction/
我已经在 macOS 上安装了最新版本的 pytest,并安装了 Homebrew 安装的 Python 2.7 并修复了它:
pip uninstall pytest
pip install pytest
Run Code Online (Sandbox Code Playgroud)
您是否有机会在Mac上使用自制软件?
我有同样的问题,它基本上归结为权限/与mac os base安装的python冲突。pip install不会安装东西或将东西链接到/ usr / local / bin(virtualenv和pytest都发生了)。
brew uninstall python)完全卸载了python 2.7 。brew install pythonsudo python -m pip uninstall pip删除root拥有画中画brew uninstall python && brew install pythonbrew link pythonpip install pytest工作了!(也是如此pip install virtualenv)我发现从这篇文章中选择的答案中的信息非常有帮助:https : //superuser.com/questions/915810/pip-not-working-on-hombrew-python-2-7-install。
如果您不在Mac电脑上,请多多包涵...
此答案假设您有 python3 和 pip3 - 如果没有,请从此答案中的命令中删除 3 。
安装 pytest 并使用命令确认它在您的 python 环境中可用后pip3 show pytest,如果您仍然收到类似zsh:command not found:pytest. 您有几个选择:
选项 1. 将库作为模块运行python3 -m pytest。
选项 2. 通过简单地创建别名来创建永久解决方案。要创建别名,请执行以下步骤:
i) 通过运行查找 shell 配置文件的位置echo $SHELL。以下是 shell 配置文件的可能位置:
例如,当我在 Mac 终端上运行时,我得到:/bin/zhs。这意味着在下一步中我需要引用该~/.zshrc文件。
ii) 一旦你弄清楚你的 shell 配置文件的名称。跑步echo "alias pytest='python3 -m pytest'" >> ~/.zshrc。这会将别名定义(在本例中为“pytest”)附加到您的 shell 配置文件中。
iii) 最后,通过编写以下命令重新加载您的配置文件:source ~/.zshrc。
测试愉快!
| 归档时间: |
|
| 查看次数: |
25711 次 |
| 最近记录: |