I think yours is a Python environment problem. To check whether it's Python environment or not, you can use which python
(or which python3
if you use Python 3) command in your both Visual Studio Code terminal and Mac terminal. If you see different python path, then your Visual Studio Code is using different python environment. You can change the Python interpreter in Visual Studio Code to have same environment as your Mac terminal.
- Open Command Palette in Visual Studio Code with ⇧ + ⌘ + P
- Type "Python: Select Interpreter"
Then, choose the same environment as your Mac terminal (if you want the same one, you can choose the same Python environment path as Mac terminal that you get with "which python" or "which python3").