Windows10下安装Python的mysqlclient失败,提示需Microsoft Visual C++10.0
Fixing "Microsoft Visual C++ 10.0 is required" when installing mysqlclient for Python 3.4
Hey, I’ve dealt with this exact error a few times when setting up mysqlclient on Windows with older Python versions like 3.4. Here’s how to get past it:
Option 1: Install the required compiler environment
The error pops up because Python 3.4 was compiled with Microsoft Visual C++ 10.0, and the mysqlclient extension needs the same compiler to build correctly. Here’s the step-by-step:
- Download and install the Microsoft Windows SDK 7.1 (which includes VC++ 10.0).
- Heads up: If you already have newer Visual Studio versions or VC++ Redistributables installed, you might hit conflicts during the SDK installation. Temporarily uninstall any VC++ 2010 Redistributable packages first, install the SDK, then reinstall the redistributables afterward to fix this.
Option 2: Use a pre-compiled wheel (easier workaround)
Compiling extensions from source can be a headache, so using a pre-built wheel is often the faster path:
- Locate a trusted source of pre-compiled wheels for mysqlclient, making sure to pick the one that matches your Python 3.4 installation and system architecture (32-bit or 64-bit).
- Once you’ve downloaded the correct
.whlfile, install it directly with pip:pip install path/to/your/mysqlclient-file-name.whl
Verify the installation
After either method, open your Python shell and run:
import MySQLdb
If you don’t get any error messages, the installation worked!
内容的提问来源于stack exchange,提问作者Jayed Khan
相关产品推荐
相关产品推荐

