ImportError: No module named flask.ext.mysql
Question:
Hi I am trying to run a python file that has :
from flask import Flask, render_template, json, request
from flask.ext.mysql import MySQL
from werkzeug import generate_password_hash, check_password_hash
I started in windows, I got the same error :
ImportError: No module named flask.ext.mysql
Someone told me don’t develop python in windows, it’s lot of headache, so I started the same project in Ubuntu, but I got the same problem :
vagrant@precise32:/vagrant/FlaskMysql/FlaskApp$ python app.py
Traceback (most recent call last):
File "app.py", line 2, in <module>
from flask.ext.mysql import MySQL
File "/usr/local/lib/python2.7/dist-packages/flask/exthook.py", line 87, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.mysql
Please your help is appreciated.
Answers:
It seems like a virtualenv config problem
you should get rid of old virtualenv and make a new one like this
virtualenv yournewvirtualenv --python=/usr/bin/python3.4
This is the link I referenced:
https://www.pythonanywhere.com/forums/topic/2877/
Here is the official Flask-MySQL documentation:
https://flask-mysql.readthedocs.org/en/latest/#
You’ll find that the current import syntax is as follows:
from flaskext.mysql import MySQL
I had the same problem, so I installed flask-mysql
using:
$ pip install flask-mysql
and the module name is flaskext.mysql
On Windows:
pip install Flask-MySQL
On Mac:
pip install flask-mysql
It’s flaskext, so…
Change
from flask.ext.mysql import MySQL
to
from flaskext.mysql import MySQL
First from flaskext.mysql import MySQL
worked then pip install Flask-MySQL
also worked finally… it was driving me nuts! I had taken to many routes to fix it.
I was facing the same error.
First I installed flask-MySQL
pip install flask-mysql
Then added below-line in app.py file
from flaskext.mysql import MySQL
It worked.
Run these commands on your terminal (one by one:
pip install flask-mysql
On your editor:
from flask import Flask
from flaskext.mysql import MySQL
# initialize your connection
Hi I am trying to run a python file that has :
from flask import Flask, render_template, json, request
from flask.ext.mysql import MySQL
from werkzeug import generate_password_hash, check_password_hash
I started in windows, I got the same error :
ImportError: No module named flask.ext.mysql
Someone told me don’t develop python in windows, it’s lot of headache, so I started the same project in Ubuntu, but I got the same problem :
vagrant@precise32:/vagrant/FlaskMysql/FlaskApp$ python app.py
Traceback (most recent call last):
File "app.py", line 2, in <module>
from flask.ext.mysql import MySQL
File "/usr/local/lib/python2.7/dist-packages/flask/exthook.py", line 87, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.mysql
Please your help is appreciated.
It seems like a virtualenv config problem
you should get rid of old virtualenv and make a new one like this
virtualenv yournewvirtualenv --python=/usr/bin/python3.4
This is the link I referenced:
https://www.pythonanywhere.com/forums/topic/2877/
Here is the official Flask-MySQL documentation:
https://flask-mysql.readthedocs.org/en/latest/#
You’ll find that the current import syntax is as follows:
from flaskext.mysql import MySQL
I had the same problem, so I installed flask-mysql
using:
$ pip install flask-mysql
and the module name is flaskext.mysql
On Windows:
pip install Flask-MySQL
On Mac:
pip install flask-mysql
It’s flaskext, so…
Change
from flask.ext.mysql import MySQL
to
from flaskext.mysql import MySQL
First from flaskext.mysql import MySQL
worked then pip install Flask-MySQL
also worked finally… it was driving me nuts! I had taken to many routes to fix it.
I was facing the same error.
First I installed flask-MySQL
pip install flask-mysql
Then added below-line in app.py file
from flaskext.mysql import MySQL
It worked.
Run these commands on your terminal (one by one:
pip install flask-mysql
On your editor:
from flask import Flask
from flaskext.mysql import MySQL
# initialize your connection