Home >Database >Mysql Tutorial >Why Does `pip install mysqlclient` Fail with 'fatal error C1083: Cannot Open File: 'mysql.h'' and How Can I Fix It?

Why Does `pip install mysqlclient` Fail with 'fatal error C1083: Cannot Open File: 'mysql.h'' and How Can I Fix It?

Barbara Streisand
Barbara StreisandOriginal
2025-01-10 14:41:41407browse

Why Does `pip install mysqlclient` Fail with

Solutionpip install mysqlclientThe installation failed and the error message was "fatal error C1083: Cannot Open File: 'mysql.h'"

When using pip to install the mysqlclient library, you may encounter the following error:

<code>fatal error C1083: Cannot open file: 'mysql.h': No such file or directory</code>

This issue is usually caused by incorrectly configured Visual Studio Build Tools or missing MySQL Connector C header files.

Solution:

To resolve this error, you can try the following steps:

  1. Use unofficial Windows binaries:

    You can download the unofficial Windows binaries for your version of Python from https://www.php.cn/link/b27c40f1f7fb35fcf65d89dc29748e29. This method can bypass the installation of Visual Studio Build Tools.

  2. Download the correct binaries:

    Locate and download the mysqlclient.whl file that corresponds to your Python version. For example, if you are using 64-bit Python 3.6, you may need to download "mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl".

  3. Install binaries:

    Install the downloaded binaries using pip:

    <code class="language-bash">pip install "下载文件的路径"</code>
  4. Confirm installation:

    Run the following command to verify the installation was successful:

    <code class="language-bash">pip show mysqlclient</code>

This method bypasses the compilation process and does not require solving header file issues.

The above is the detailed content of Why Does `pip install mysqlclient` Fail with 'fatal error C1083: Cannot Open File: 'mysql.h'' and How Can I Fix It?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn