Home > Blockchain >  ModuleNotFoundError: No module named 'pytest' in IntelliJ IDEA
ModuleNotFoundError: No module named 'pytest' in IntelliJ IDEA

Time:11-18

I am new to python and trying to run code from existing project. I am getting the below error:

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'

The file is present in the mentioned path. I see that there are many questions regarding this but nothing seems to provide me with a solution. I am using the IntelliJ IDEA IDE.

CodePudding user response:

The error message is telling you that File "/xxxx/xxxx/Library/Application Support/JetBrains/IdeaIC2021.1/plugins/python-ce/helpers/pycharm/_jb_pytest_runner.py" is trying to import pytest but fails to find the package. That is, it's not the presence of that file that's failing, but that it can't find pytest in order to import it.

Install pytest using

python3 -m pip install pytest

Change python3 accordingly to use the specific installation of python that you're using in the IDE.

CodePudding user response:

This is because you don't have the needed environment. Since you use the Pycharm, you can try to install pytest. https://blog.finxter.com/how-to-install-a-library-on-pycharm/

  • Related