I have successfully installed Python 3 utilizing Homebrew and can readily execute Python 3 commands within the terminal, as well as run my scripts without any issues.
However, I’m encountering a challenge when trying to execute my code within Visual Studio Code. I consistently receive the following error upon attempting to run my script:
Traceback (most recent call last):
File "/Users/zen/Desktop/W/coding/Scan/test.py", line 1, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
This issue persists for other import statements as well. Notably, simpler commands such as print('hello world')
execute flawlessly.
I’ve ensured that the path to my Python interpreter is correctly specified in the settings.json file of VS Code.
Would anyone be able to provide assistance regarding this matter?
2
Answers
I just solved the error by going into the code runner settings.json, executer map and change
into
For people who has same problems.
You need to install the package in Visual Studio Code. Start a new terminal session in VS code and enter the following
pip install opencv-python