You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

CentOS7下pip安装Python3.6的mysqlclient遇依赖冲突问题求助

Fixing mysqlclient Installation Errors on CentOS (OSError: mysql_config not found + MariaDB/MySQL Conflicts)

Hey, I’ve dealt with this exact set of issues on CentOS before—let’s walk through the solutions depending on whether you want to stick with MariaDB or switch to MySQL’s official packages.

Option 1: Use MariaDB’s Development Package (No Conflict, Easiest Fix)

Since mysqlclient is fully compatible with MariaDB’s development files, you don’t need to mess with MySQL’s packages at all. Just install the MariaDB 10.1 development package that matches your existing MariaDB version:

yum install mariadb101u-devel

Once that’s done, go ahead and install mysqlclient again—it should find mysql_config now:

pip install mysqlclient

Option 2: Switch to MySQL’s Official Packages (If You Need MySQL-Specific Features)

If you really need to use MySQL’s official development libraries, you’ll first have to resolve the package conflicts by removing the conflicting MariaDB packages. Warning: This might break existing MariaDB services, so back up your data and stop any running MariaDB processes first!

  1. Remove the conflicting MariaDB packages:
yum remove mariadb101u-config mariadb101u-libs
  1. Enable MySQL’s official YUM repository:

    • Grab the MySQL repo file for CentOS 7 from MySQL’s official website, save it to your server, then install it using:
    yum localinstall mysql80-community-release-el7-3.noarch.rpm
    
  2. Install MySQL’s development package:

yum install mysql-community-devel
  1. Finally, install mysqlclient:
pip install mysqlclient

Quick Troubleshooting Tip

If you still run into issues after installing the development package, double-check that mysql_config is in your system path. You can verify this with:

which mysql_config

If it shows up, you’re good to go. If not, you can temporarily set the path before running pip:

export PATH=$PATH:/usr/bin/mysql_config
pip install mysqlclient

内容的提问来源于stack exchange,提问作者Djent

火山引擎 最新活动