安装 flask-mysqldb 给出 "mysql_config not found"
Installing flask-mysqldb gives "mysql_config not found"
我正在尝试在 ubuntu 18.04 上安装 flask-mysql
,但我一直收到此错误:
(base) ether@ether:~/Documents/loginsystem$ pip install flask-mysqldb
Collecting flask-mysqldb
Using cached https://files.pythonhosted.org/packages/62/e3/955c845efe1aacf30c8e2607470544ede36aa1044f6382c809f13e014104/Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in /home/ether/anaconda3/lib/python3.7/site-packages (from flask-mysqldb) (1.0.2)
Collecting mysqlclient (from flask-mysqldb)
Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-txlk8w2u/mysqlclient/
我尝试 运行 sudo pip install
和 pip3 install flask-mysqldb
但每次我都收到与上面发布的相同的错误。
我该怎么做才能解决这个问题?
错误信息很清楚:
OSError: mysql_config not found
您需要 mysql_config
。使用 apt
.
安装 either libmariadbclient-dev
or libmysqlclient-dev
然后尝试再次使用 pip
,但 不是 和 sudo
。
混合使用系统级 Python 软件包和 pip
安装的软件包是灾难的根源。看起来你的项目已经有一个 virtualenv,所以使用它。如果您在 requirements.txt
文件或 Pipfile
.
中指定依赖项,则可获得加分
我正在尝试在 ubuntu 18.04 上安装 flask-mysql
,但我一直收到此错误:
(base) ether@ether:~/Documents/loginsystem$ pip install flask-mysqldb
Collecting flask-mysqldb
Using cached https://files.pythonhosted.org/packages/62/e3/955c845efe1aacf30c8e2607470544ede36aa1044f6382c809f13e014104/Flask-MySQLdb-0.2.0.tar.gz
Requirement already satisfied: Flask>=0.10 in /home/ether/anaconda3/lib/python3.7/site-packages (from flask-mysqldb) (1.0.2)
Collecting mysqlclient (from flask-mysqldb)
Using cached https://files.pythonhosted.org/packages/d0/97/7326248ac8d5049968bf4ec708a5d3d4806e412a42e74160d7f266a3e03a/mysqlclient-1.4.6.tar.gz
Complete output from command python setup.py egg_info:
/bin/sh: 1: mysql_config: not found
/bin/sh: 1: mariadb_config: not found
/bin/sh: 1: mysql_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup.py", line 16, in <module>
metadata, options = get_config()
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "/tmp/pip-install-txlk8w2u/mysqlclient/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
OSError: mysql_config not found
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-txlk8w2u/mysqlclient/
我尝试 运行 sudo pip install
和 pip3 install flask-mysqldb
但每次我都收到与上面发布的相同的错误。
我该怎么做才能解决这个问题?
错误信息很清楚:
OSError: mysql_config not found
您需要 mysql_config
。使用 apt
.
libmariadbclient-dev
or libmysqlclient-dev
然后尝试再次使用 pip
,但 不是 和 sudo
。
混合使用系统级 Python 软件包和 pip
安装的软件包是灾难的根源。看起来你的项目已经有一个 virtualenv,所以使用它。如果您在 requirements.txt
文件或 Pipfile
.