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?
Solutionpip install mysqlclient
The 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:
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.
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".
Install binaries:
Install the downloaded binaries using pip:
<code class="language-bash">pip install "下载文件的路径"</code>
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!