我是python的新手,正在尝试从现有项目中运行代码。我得到以下错误:
Traceback (most recent call last):
File "/xxxx/xxxx/Library/Application Support/JetBrains/IdeaIC2021.1/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py", line 2, in <module>
import pytest
ModuleNotFoundError: No module named 'pytest'该文件位于上述路径中。我看到有很多关于这方面的问题,但似乎没有什么能为我提供解决方案。我使用的是IntelliJ IDEA集成开发环境。
发布于 2021-11-18 06:56:16
错误消息告诉您File "/xxxx/xxxx/Library/Application Support/JetBrains/IdeaIC2021.1/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py"正在尝试导入pytest,但找不到包。也就是说,失败的不是该文件的存在,而是它找不到pytest来导入它。
使用安装pytest
python3 -m pip install pytest相应地更改python3,以使用您在IDE中使用的特定python安装。
发布于 2021-11-18 06:55:26
这是因为您没有所需的环境。由于您使用的是Pycharm,因此可以尝试安装pytest。https://blog.finxter.com/how-to-install-a-library-on-pycharm/
https://stackoverflow.com/questions/70015583
复制相似问题