Skip to content Skip to sidebar Skip to footer

Flask Import Error (python)

Trying to import flask but I get the error: ImportError: No module named Flask after: import Flask I just installed it using terminal (Mac OS X): JoeDangers-MacBookPro:~ joedange

Solution 1:

The module is called flask:

from flask importFlask

Solution 2:

You can use virtual environment

$ pip install virtualenv

Create virtualenv:

$ virtualenv venv

  • *venv is virtual environment name. Just name it what u want.

Activate virtual environment:

$ source venv/bin/activate

Make sure your terminal like this:

(venv) user@username:

Installing flask

pip install flask

And you can import flask without error :)

To deactivate, just type:

deactivate

Solution 3:

uninstall the package and then reinstall it again using pip " pip install Flask " after that use this command to import the package:

from flask importFlask

edit: are you using virtualenv ? if not then i recommend you to install it first use this command:

pip install python-virtualenv 

Solution 4:

If your using mac terminal then check the python version which is linked to pip. Suppose for example if pip is linked to python version 2.7 use

➜  ~ python
Type"help", "copyright", "credits"or"license"for more information.
>>> import flask

(or) 

➜  ~ python app.py

else if python version is 3.0 and above

➜  ~ python3
Type"help", "copyright", "credits"or"license"for more information.
>>> import flask

(or)

➜  ~ python3 app.py

By using these commands you can check is flask is installed and if so for which python version

Post a Comment for "Flask Import Error (python)"