python - 如何在我的 python 虚拟环境中设置 pytest
问题描述
我按照https://sourabhbajaj.com/mac-setup/Python/virtualenv.html中的步骤在我的目录中设置一个 python 虚拟环境,我python -m venv testEnv
做了source venv/bin/activate
。我在 MacOSX 和 zsh 上。
但是当我这样做时pytest
,我会收到类似的错误
$ pytest
zsh: /Library/Frameworks/Python.framework/Versions/3.8/bin/pytest: bad interpreter: /usr/local/bin/python3: no such file or directory
这些是我的 python 和 pytest
❯ which python testEnv
python: aliased to /Users/hap497/.pyenv/shims/python
❯ which pytest testEnv
/Library/Frameworks/Python.framework/Versions/3.8/bin/pytest
那么我需要做什么才能在我的虚拟环境中设置 python 和 pytest?
解决方案
如果你做了
python -m venv testEnv
那你想要
source testEnv/bin/activate
并不是
source venv/bin/activate
我们可以在which
输出中看到 pytest 未正确安装到您的 venv。正确激活 testEnv 并再次安装 pytest。
推荐阅读
- firebase - 在 Vue CLI 项目中初始化 Firebase 和 ServiceWorkert 时,移动网页为空白
- ios - Xcode 的助理代码编辑器中是否有“简化”的代码视图?
- r - 如果两个dfs中的两个“age”变量在R中匹配,如何将新列添加到作为变量“hr”的-ln的数据框中?
- wordpress - How to use upgrader_process_complete hook in WordPress to check for spcific plugin update
- google-classroom - 如果我使用与我共享的表单在 Google 课堂上创建作业,谁会看到提交的内容?
- javascript - 从javascript函数spring boot thymeleaf js内部设置模型属性var
- java - asp MVC存储库中的返回类型问题
- perl - IPC::System::Simple capturex 是如何工作的?
- javascript - 如何获取 async / await 函数的结果?
- excel - 根据另一个单元格对一个单元格进行颜色格式化