我尝试将flask-mysql从pip3安装到python3,但它会抛出异常。 这是日志。
Running setup.py (path:/tmp/pip-build-j2hw4zsz/MySQL-python/setup.py) egg_info for package MySQL-python
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip-build-j2hw4zsz/MySQL-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/tmp/pip-build-j2hw4zsz/MySQL-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip-build-j2hw4zsz/MySQL-python/setup.py", line 13, in <module>
from setup_posix import get_config
File "/tmp/pip-build-j2hw4zsz/MySQL-python/setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
那么,如何将flask-mysql安装到python3?
P.S。我尝试用&#34; pip3安装flask-mysql&#34;和&#34; pip install Flask ... whl&#34;。
答案 0 :(得分:5)
Flask-MySQL使用MySQL-Python,它不支持Python 3,并且已经有open issue about it超过一年。请改用Flask-MySQLdb,它使用MySQLclient。
pip install flask-mysqldb
或者使用SQLAlchemy,一个更强大的界面来处理数据库。
pip install flask-sqlalchemy mysqlclient
答案 1 :(得分:0)
这对我有用:
sudo pip install flask-mysqldb