1

我正在构建一个烧瓶项目,我想使用 MySQL 数据库。我需要flask-mysqldb 作为ORM。所以作为一个好的实践,我创建了一个虚拟环境,安装了flask和其他依赖项,然后为了安装flask-mysqldb,我使用了pip install flask-mysqldb. 这突然给了我一堆错误。起初我意识到,我的系统上没有安装 MySQL。因此,即使在安装之后,这些错误也不会消失。我也试过pip install Flask-MySQLdb不知道这与第一个命令有何不同,但错误相同。

我尝试在线搜索有关 flask-mysqldb 的错误,但其中大多数与mysql.h我的终端日志中未显示的一些文件错误有关。

(env) ck@ck-IdeaPad-Gaming-3-15ARH05:~/projects/opensoft/roomAlloc$ pip install Flask-MySQLdb
Collecting Flask-MySQLdb
  Using cached Flask-MySQLdb-0.2.0.tar.gz (2.1 kB)
Requirement already satisfied: Flask>=0.10 in ./env/lib/python3.8/site-packages (from Flask-MySQLdb) (2.0.2)
Collecting mysqlclient
  Using cached mysqlclient-2.1.0.tar.gz (87 kB)
    ERROR: Command errored out with exit status 1:
     command: /home/ck/projects/opensoft/roomAlloc/env/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-bra67idg/mysqlclient/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bra67idg/mysqlclient/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-bra67idg/mysqlclient/pip-egg-info
         cwd: /tmp/pip-install-bra67idg/mysqlclient/
    Complete output (15 lines):
    /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-bra67idg/mysqlclient/setup.py", line 15, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-bra67idg/mysqlclient/setup_posix.py", line 70, in get_config
        libs = mysql_config("libs")
      File "/tmp/pip-install-bra67idg/mysqlclient/setup_posix.py", line 31, in mysql_config
        raise OSError("{} not found".format(_mysql_config_path))
    OSError: mysql_config not found
    mysql_config --version
    mariadb_config --version
    mysql_config --libs
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

请帮助我,如果您需要更多信息,可以发表评论。

4

1 回答 1

0

2分钟前我有同样的错误,找到这个命令来解决问题!

sudo apt-get install libmysqlclient-dev

只是尝试再次安装,应该可以正常工作。

学分:

我在这里找到了这个命令(西班牙语):

https://programmerclick.com/article/1483761552/

于 2022-02-19T17:41:33.723 回答