Litchy
Litchy

Reputation: 363

No module named ... in PyCharm (import error)

I am using PyCharm on MAC to import some packages by

import pymongo
import bson

However the error is ModuleNotFoundError: No module named 'pymongo'

The packages are installed successfully and there is nothing wrong when running them in the command line I also checked the Interpreter Configuration in Pycharm, fixed to Python 3.6(my only version of Python 3)

Also, when I use pip3 freeze it indicates that these packages are successfully installed

How can I fix this problem?

Upvotes: 3

Views: 16006

Answers (2)

ryy77
ryy77

Reputation: 1294

Delete the venv folder and then add the interpreter again from Settings>Project Interpreter. After that add the packages again(pip install package-name)

Upvotes: 0

Marcel
Marcel

Reputation: 1463

You're running Python in a virtual environment (venv), the packages you installed via pip cannot be found in this environment.

At the project interpreter, click the plus (+) sign at the bottom and add your packages there.

Project interpreter

Click the + at the bottom

Install package Search for, and install your package

Upvotes: 7

Related Questions