To solve ImportError: No module named mock error follow below methods.
ERROR LOG
ImportError: No module named mock
Contents
How to solve ImportError: No module named mock ?
Refer the given methods to solve the issue.
Method 1:
unittest
is a built-in module; mock
is an external library . After installing mock
via pip install mock
, you import it not by using
from unittest.mock import MagicMock
but
from mock import MagicMock
Edit: mock
has been included in the unittest
module, and can be imported by import unittest.mock
.
Hope the above solution works.
Also read :
Python AttributeError: ‘module’ object has no attribute ‘Serial’
Python: import cx_Oracle ImportError: No module named cx_Oracle error is thown