0

Im trying to run python routes.py (inside a virtual environment) to get my routes to be updated, but when i run that, i get:

  File "routes.py", line 1, in <module>
    from flask import Flask, render_template
ImportError: No module named 'flask'

If I then try to install flask like pip install flask i get that its INSTALLED already

my routes.py looks like:

from flask import Flask, render_template
from forms import EmailUsForm

app = Flask(__name__)

app.secret_key = '12345'

@app.route('/')
def home():
    form=EmailUsForm()
    return render_template('index.html', form=form)

If I type: python then import Flask or from Flask import * I get:

ImportError: No module named 'Flask'

Any idea what is going on here?

Thank you.

4
  • 1
    You are using a python executable that doesn't have Flask installed. Install Flask for that executable. If you are using a virtual environment, make sure you installed Flask there.
    – Martijn Pieters
    Dec 11, 2016 at 15:54
  • Please see updated. Something doesnt seem right
    – Jshee
    Dec 11, 2016 at 15:58
  • Do you see Flask if you use python -m pip list?
    – dirn
    Dec 11, 2016 at 16:09
  • No, but it thinks its already installed? (in virtualenv). Im running python 3.5.2
    – Jshee
    Dec 11, 2016 at 16:11

1 Answer 1

0

U have to install Flask in your virtual environment, Since you are using Python3.x, use

pip3 install flask

Because if you use pip it will be installed for Python2.x by default

12
  • If I do this with the env enabled, it says: sudo: pip3: command not found
    – Jshee
    Dec 11, 2016 at 16:20
  • Then you should first install pip for python 3 by sudo apt-get install python3-pip Dec 11, 2016 at 16:23
  • Or you can refer this post stackoverflow.com/questions/6587507/… Dec 11, 2016 at 16:24
  • I then, installed flask via pip3, but if i try to run python routes.py it says it cant find flask
    – Jshee
    Dec 11, 2016 at 16:24
  • Requirement already satisfied: flask in /usr/local/lib/python3.5/dist-packages. If i then try to import it via python then from flask import * or import flask it says ImportError: No module named 'flask'
    – Jshee
    Dec 11, 2016 at 16:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.