CentOS7下pip安装Python3.6的mysqlclient遇依赖冲突问题求助
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!
- Remove the conflicting MariaDB packages:
yum remove mariadb101u-config mariadb101u-libs
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.rpmInstall MySQL’s development package:
yum install mysql-community-devel
- 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




