How to fix mysqlclient error?

Hello everyone. When I install mysqlclient package get me error. I search on internet how to fix it but I cannot find good.

[    ] Installing mysqlclient...[31m[1mError: [0m An error occurred while installing [32mmysqlclient[0m!
Error text: Requirement already satisfied: mysqlclient in c:\users\feruz\.virtualenvs\storefront-gd3epr4w\lib\site-packages (from -r 
c:\users\feruz\appdata\local\temp\pipenv-5tosxs2v-requirements\pipenv-dv4a1lfr-requirement.txt (line 1)) (1.4.6)
Collecting mysqlclient
  Using cached mysqlclient-2.1.1.tar.gz (88 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py): started
  Building wheel for mysqlclient (setup.py): finished with status 'error'
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Attempting uninstall: mysqlclient
    Found existing installation: mysqlclient 1.4.6
    Uninstalling mysqlclient-1.4.6:
      Successfully uninstalled mysqlclient-1.4.6
  Running setup.py install for mysqlclient: started
  Running setup.py install for mysqlclient: finished with status 'error'
  Rolling back uninstall of mysqlclient
  Moving to c:\users\feruz\.virtualenvs\storefront-gd3epr4w\lib\site-packages\mysqlclient-1.4.6.dist-info\
   from C:\Users\Feruz\.virtualenvs\storefront-GD3EPR4W\Lib\site-packages\~ysqlclient-1.4.6.dist-info
  Moving to c:\users\feruz\.virtualenvs\storefront-gd3epr4w\lib\site-packages\mysqldb\
   from C:\Users\Feruz\.virtualenvs\storefront-GD3EPR4W\Lib\site-packages\~ysqldb

[  ==] Installing mysqlclient...[36m  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [31 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win32-cpython-38
      creating build\lib.win32-cpython-38\MySQLdb
      copying MySQLdb\__init__.py -> build\lib.win32-cpython-38\MySQLdb
      copying MySQLdb\_exceptions.py -> build\lib.win32-cpython-38\MySQLdb
      copying MySQLdb\connections.py -> build\lib.win32-cpython-38\MySQLdb
      copying MySQLdb\converters.py -> build\lib.win32-cpython-38\MySQLdb
      copying MySQLdb\cursors.py -> build\lib.win32-cpython-38\MySQLdb
      copying MySQLdb\release.py -> build\lib.win32-cpython-38\MySQLdb
      copying MySQLdb\times.py -> build\lib.win32-cpython-38\MySQLdb
      creating build\lib.win32-cpython-38\MySQLdb\constants
      copying MySQLdb\constants\__init__.py -> build\lib.win32-cpython-38\MySQLdb\constants
      copying MySQLdb\constants\CLIENT.py -> build\lib.win32-cpython-38\MySQLdb\constants
      copying MySQLdb\constants\CR.py -> build\lib.win32-cpython-38\MySQLdb\constants
      copying MySQLdb\constants\ER.py -> build\lib.win32-cpython-38\MySQLdb\constants
      copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-cpython-38\MySQLdb\constants
      copying MySQLdb\constants\FLAG.py -> build\lib.win32-cpython-38\MySQLdb\constants
      warning: build_py: byte-compiling is disabled, skipping.

      running build_ext
      building 'MySQLdb._mysql' extension
      creating build\temp.win32-cpython-38
      creating build\temp.win32-cpython-38\Release
      creating build\temp.win32-cpython-38\Release\MySQLdb
      "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\bin\HostX86\x86\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG  
/MD -Dversion_info=(2,1,1,'final',0) -D__version__=2.1.1 "-IC:\Program Files (x86)\MariaDB\MariaDB Connector C\include\mariadb" "-IC:\Program Files      
(x86)\MariaDB\MariaDB Connector C\include" -IC:\Users\Feruz\.virtualenvs\storefront-GD3EPR4W\include
-Ic:\users\feruz\appdata\local\programs\python\python38-32\include -Ic:\users\feruz\appdata\local\programs\python\python38-32\Include "-IC:\Program Files(x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.34.31933\include" "-IC:\Program Files (x86)\Microsoft Visual 
Studio\2022\BuildTools\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows   
Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows 
Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" "-IC:\Program Files (x86)\Windows       
Kits\NETFXSDK\4.8\include\um" /TcMySQLdb/_mysql.c /Fobuild\temp.win32-cpython-38\Release\MySQLdb/_mysql.obj
      _mysql.c
      MySQLdb/_mysql.c(29): fatal error C1083: ЌҐ г¤ Ґвбп ®вЄалвм д ©« ўЄ«о祭ЁҐ: mysql.h: No such file or directory,
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x86\\cl.exe' failedwith exit code 2


  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mysqlclient
  error: subprocess-exited-with-error
  
  × Running setup.py install for mysqlclient did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      running install
      C:\Users\Feruz\.virtualenvs\storefront-GD3EPR4W\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install 
is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build\lib.win32-cpython-38
      creating build\lib.win32-cpython-38\MySQLdb
      copying MySQLdb\__init__.py -> build\lib.win32-cpython-38\MySQLdb
      copying MySQLdb\_exceptions.py -> build\lib.win32-cpython-38\MySQLdb
      MySQLdb/_mysql.c(29): fatal error C1083: ЌҐ г¤ Ґвбп ®вЄалвм д ©« ўЄ«о祭ЁҐ: mysql.h: No such file or directory,
      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.34.31933\\bin\\HostX86\\x86\\cl.exe' failedwith exit code 2


  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> mysqlclient

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
[0m
Installation Failed

This has been answered a few times on this forum, please search for the best one for your platform.

The error is due to your ~/.bashrc or ~/.zshrc file doesn’t have django path properly point.
It took me 3 days to fix the error after several searching here and there

  1. Add django to your path. open python, import django, then run django to see django’s path. then add it to your ~/.bashrc (or ~/.zshrc if you’re using zsh). more info in here

export PATH =" put your path here "

Save the file and that should solve the problem :heart_eyes: