如何为python3安装flask

如何为python3安装flask

本文介绍了如何为python3安装flask-mysql?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将flask-mysql从pip3安装到python3,但是会引发异常.这是日志.

I tried to install flask-mysql from pip3 to python3, but it throws exception.Here is log.

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?

So, how to install flask-mysql to python3?

P.S.我尝试同时使用"pip3 install flask-mysql"和"pip install Flask ... whl"进行安装.

P.S. I tried to install both with "pip3 install flask-mysql" and "pip install Flask...whl".

推荐答案

Flask-MySQL使用MySQL-Python,它不支持Python 3,并且存在与此相关的公开问题已超过一年.改用Flask-MySQLdb,它使用MySQLclient.

Flask-MySQL uses MySQL-Python, which doesn't support Python 3, and there has been an open issue about it for over a year. Use Flask-MySQLdb instead, which uses MySQLclient.

pip install flask-mysqldb

或者使用SQLAlchemy,这是用于处理数据库的更强大的界面.

Or use SQLAlchemy, a much more powerful interface for working with databases.

pip install flask-sqlalchemy mysqlclient

这篇关于如何为python3安装flask-mysql?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 19:13