Abrar Hossain
Abrar Hossain

Reputation: 109

ModuleNotFoundError when trying to access Flask Package from PyCharm

I am beginner, learning Python for about a month. I was trying to build a web framework in Python. I installed Flask as a package using pip, but when I tried to access it from PyCharm, it showed an error:

ModuleNotFoundError: No module named 'flask'

I have included some screenshots.

This image shows the error I am getting:

image

This image shows I have Flask successfully installed in the system:

image

What could be the problem? And How do I solve it?

P.S: I am able to access the package from the command window. It's only when I am trying to access from Pycharm, the error occurs.

Upvotes: 1

Views: 2496

Answers (2)

VikrantArya
VikrantArya

Reputation: 71

I was getting this error in flask 1.1.* with pycharm, after installing the lower version in the virtual environment, It is working fine.

Upvotes: 1

Bram Vanroy
Bram Vanroy

Reputation: 28437

You probably started a new project using a virtual environment (venv), which is good practice. But then you installed flask globally into Python, which doesn't affect already created environments. Therefore, Flask is not available in your project's virtual environment.

As an extension to Robin Zegmond's comment: instead of installing your package through the command line, you can install it through PyCharm. This ensures that the packages you install are installed for the right interpreter/environment.

  1. File > Settings > Project: > Project Interpreter
  2. Click the '+' sign on the right
  3. Search for your module and install, this may take some time depending on the module.

Upvotes: 5

Related Questions