大家好!我目前正在使用python(flask)制作的网站,但是当我尝试为python安装MYSQLDB时,我遇到了一个问题。我想将它用于我可以存储用户和其他数据的数据库。首先,输入时是终端输出:
pip install flask-mysqldb
Collecting flask-mysqldb
Using cached Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from flask-mysqldb)
Collecting mysqlclient (from flask-mysqldb)
Using cached mysqlclient-1.3.12.tar.gz
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/b3/4tr2p1w10cx70rqpqh28m30r0000gn/T/pip-build-4sX19x/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/b3/4tr2p1w10cx70rqpqh28m30r0000gn/T/pip-build-4sX19x/mysqlclient/
此错误消息对我没有任何帮助,我不知道如何处理它。在收到错误后,我在不同的网站上搜索了一个解决方案,但没有一个解决方案适合我。以下是一些解决方案&#39;我试过了
sudo pip3 install git+https://github.com/donnemartin/gitsome.git
sudo -H pip3 install gitsome
sudo pip install --upgrade setuptools
当我输入时:
sudo -H pip install flask-mysqldb
这是输出:
Collecting flask-mysqldb
Downloading Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from flask-mysqldb)
Collecting mysqlclient (from flask-mysqldb)
Downloading mysqlclient-1.3.12.tar.gz (89kB)
100% |████████████████████████████████| 92kB 556kB/s
Complete output from command python setup.py egg_info:
sh: mysql_config: command not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/tmp/pip-build-P4Y1ub/mysqlclient/setup.py", line 17, in <module>
metadata, options = get_config()
File "setup_posix.py", line 44, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 26, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-P4Y1ub/mysqlclient/
我真的很感激有任何帮助来解决这个问题!提前谢谢。
答案 0 :(得分:0)
如果您关注的是操纵数据库,我建议使用Flask-SQLAlchemy和right here您将找到如何使用MySQL数据库进行连接。
Flask-SQLAlchemy是一个ORM(对象关系映射器)所以,你可能需要代码映射数据库
我希望这有帮助!