Search code examples
pythonmacosvisual-studio-codeimporterror

No module named [mtcnn] - m1 Mac - python


I am trying to import the module mtcnn in VSCode. I have run the following commands in the terminal:

pip3 install MTCNN

and

python3.8 -m pip install mtcnn

Which downloads MTCNN

Terminal showing its already installed

But when I try run my python file in VSCode, I run into this error: Error

I am using python version 3.8.5 in VSCode. There is no red line error under the import line in VSCode so I'm confused why it's not working.


Solution

    1. Open an integrated terminal in VS Code, run python --version to check if it's as the same as the one you selected for python interpreter, which is shown in status bar.
    2. Run pip show mtcnn. If you get detailed information like name, version and location, reload window should solve your question. enter image description here If you get WARNING: Package(s) not found: mtcnn, it means no such module in your current selected environment, install it. enter image description here

    Besides, to avoid messing up the global python environment, you may create a virtual environment. See Create a Virtual Environment.