安装flask-mysqldb时报错

使用 pip install 安装 flask-mysqldb 的时候,python底层依赖于一个底层的模块 mysqlclinent 模块。如果没有这个模块则会报错如下:

WARNING: Discarding https://files.pythonhosted.org/packages/6a/91/bdfe808fb5dc99a5f65833b370818161b77ef6d1e19b488e4c146ab615aa/mysqlclient-1.3.0.tar.gz#sha256=06eb5664e3738b283ea2262ee60ed83192e898f019cc7ff251f4d05a564ab3b7 (from https://pypi.org/simple/mysqlclient/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Collecting flask_mysqldb
  Using cached Flask-MySQLdb-0.1.1.tar.gz (2.0 kB)
ERROR: Cannot install flask-mysqldb==0.1.1 and flask-mysqldb==0.2.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    flask-mysqldb 0.2.0 depends on mysqlclient
    flask-mysqldb 0.1.1 depends on mysqlclient

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

解决方案:

sudo apt-get install -y libmysqlclient-dev python3-dev

# 运行上面的安装命令如果再次报错如下:
#   dpkg 被中断,您必须手工运行 ‘sudo dpkg --configure -a’ 解决此问题。

# 则根据提示执行命令以下命令,再次安装mysqlclient
#    sudo dpkg --configure -a
#    apt-get install libmysqlclient-dev python3-dev

解决了mysqlclient问题以后,重新安装 flask-mysqldb即可。
pip install flask-mysqldb -i https://pypi.tuna.tsinghua.edu.cn/simple
posted @ 2022-02-10 17:13  vetra  阅读(491)  评论(0)    收藏  举报