pip安装mysql-python失败求助:gcc报/Zl不存在错误(WinPython3.4)
mysql-python Installation Error with Python 3.4 Hey there, let's get this sorted out quickly. The root cause of your error is straightforward: mysql-python (the package you're trying to install) only supports Python 2.x, but you're running Python 3.4. That's why you're hitting that confusing /Zl compiler error—this package's build scripts are designed for Python 2 and Microsoft's MSVC compiler, not Python 3 + MinGW.
Updating pip/setuptools/wheels won't fix this because it's a version compatibility issue, not a tooling problem. Here are your best solutions:
Solution 1: Use mysqlclient (Recommended)
mysqlclient is the official Python 3-compatible fork of mysql-python, and it works exactly the same way as the original package. To install it:
pip install mysqlclient
If you still hit compilation issues on Windows, skip the source build by downloading a pre-compiled wheel file matching your Python 3.4 64-bit environment, then install it directly:
pip install path/to/mysqlclient-<version>-cp34-none-win_amd64.whl
Solution 2: Use pymysql (No Compilation Needed)
If you want to avoid compilation entirely, pymysql is a pure-Python MySQL client that works seamlessly with Python 3. Install it with:
pip install pymysql
To make it drop-in compatible with code that expects MySQLdb, add this at the start of your script:
import pymysql pymysql.install_as_MySQLdb()
Your existing import MySQLdb code will work without any changes.
Solution 3 (Not Recommended): Downgrade to Python 2.7
If you absolutely must use the original mysql-python package, you'd have to downgrade your Python version to 2.7. However, Python 2 reached end-of-life years ago, so this is not advised for security and compatibility reasons.
内容的提问来源于stack exchange,提问作者Fancypants753

