0

I amd getting: ModuleNotFoundError: No module named 'flask', when trying to run a file that starts

from flask import Flask

  • i am using PyCharm on Ubuntu VM. Opened the terminal under venv directory. this is what i am getting:
~/PycharmProjects/project01/venv$ python -m flask --versionFlask 1.0.2
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15) 
[GCC 7.3.0]

why does my interpreter can't find the flask module (i am guessing this is not specific to flask)? tried to browse through some previous suggested solution like this: ModuleNotFoundError: No module named 'flask' but it didn't solve the problem Made sure my PyCharm project interpreter is pointing to /home/my_user/PycharmProjects/project01/venv/bin/python and not another interpreter The only way i could have solved it is by installing the flask through the PyCharm Gui, but i really would like to understand why installing from the terminal with pip install flask didn't work

1 Answers1

0

source venv/bin/activate

And install flask on the venv; after run the script using the venv python binary. - I believe you either have not installed flask in the virtual environment or you're not using the virtual environment python.

To check which python binary you're invoking:

whereis python

Julian Camilleri
  • 2,975
  • 1
  • 25
  • 34
  • yes, that did the trick! i guess flask was not installed on that environment. so what does it mean the output that i am getting when i ask from the terminal **python -m flask --versionFlask** where does it prints the version of flask from? – Yoni Tzafrir Apr 22 '19 at 18:59
  • Your `/usr/bin/python` - you can use `whereis python` to see which python binary you're using. - If it helps and answers your question, mark it as your answer. – Julian Camilleri Apr 23 '19 at 17:12