I am trying to use django and use mysql as the database. i originally had it working just fine but i recently changed the name of the user account and that is where everything has gone wrong. I have used pip install mysqlclient but the error below is what i get. Is there a way to install mysqlclient another way?
I am using django's newest version and i am using visual code. Thank you
ERROR: Command errored out with exit status 1:
command: 'c:\users\jacob\appdata\local\programs\python\python37-32\python.e
xe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\JACOB
\\AppData\\Local\\Temp\\pip-install-ehb3yr50\\mysqlclient\\setup.py'"'"'; __file
__='"'"'C:\\Users\\JACOB\\AppData\\Local\\Temp\\pip-install-ehb3yr50\\mysqlclien
t\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read
().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__,
'"'"'exec'"'"'))' install --record 'C:\Users\JACOB\AppData\Local\Temp\pip-record
-hbel0tdu\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\JACOB\AppData\Local\Temp\pip-install-ehb3yr50\mysqlclient
\
Complete output (30 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\_exceptions.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-3.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-3.7\MySQLdb
creating build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-3.7\MySQLdb\constan
ts
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-3.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.7\MySQLdb\const
ants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants
running build_ext
building 'MySQLdb._mysql' extension
creating build\temp.win32-3.7
creating build\temp.win32-3.7\Release
creating build\temp.win32-3.7\Release\MySQLdb
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\
14.22.27905\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -Dversion
_info=(1,4,4,'final',0) -D__version__=1.4.4 "-IC:\Program Files (x86)\MySQL\MySQ
L Connector C 6.1\include\mariadb" -Ic:\users\jacob\appdata\local\programs\pytho
n\python37-32\include -Ic:\users\jacob\appdata\local\programs\python\python37-32
\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Too
ls\MSVC\14.22.27905\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual S
tudio\2019\Community\VC\Tools\MSVC\14.22.27905\include" "-IC:\Program Files (x86
)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits
\10\include\10.0.18362.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include
\10.0.18362.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.183
62.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt" "
-IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt" /TcMySQL
db/_mysql.c /Fobuild\temp.win32-3.7\Release\MySQLdb/_mysql.obj /Zl /D_CRT_SECURE
_NO_WARNINGS
_mysql.c
MySQLdb/_mysql.c(29): fatal error C1083: Cannot open include file: 'mysql.h'
: No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Comm
unity\\VC\\Tools\\MSVC\\14.22.27905\\bin\\HostX86\\x86\\cl.exe' failed with exit
status 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\jacob\appdata\local\pro
grams\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sy
s.argv[0] = '"'"'C:\\Users\\JACOB\\AppData\\Local\\Temp\\pip-install-ehb3yr50\\m
ysqlclient\\setup.py'"'"'; __file__='"'"'C:\\Users\\JACOB\\AppData\\Local\\Temp\
\pip-install-ehb3yr50\\mysqlclient\\setup.py'"'"';f=getattr(tokenize, '"'"'open'
"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.clos
e();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\JA
COB\AppData\Local\Temp\pip-record-hbel0tdu\install-record.txt' --single-version-
externally-managed --compile Check the logs for full command output.
go to this site to download the package according to the python version. and use pip install filename like i have python 3.7.1 and download the file in red circle and open terminal where file downloaded and install that file e.g pip install mysqlclient-1.4.4-cp37-cp37m-win32.whl
and in setting file
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'shoping_cart',
'HOST': 'localhost',
'USER': 'root',
'PASSWORD':'',
'PORT': '3306',
}
}
For Linux users
First, install the following dependencies:
sudo apt-get install python3.9-dev libmysqlclient-dev
# don't forget to change python version as per your virtual environment
# since I created my virtual environment with python3.9 that is why I
# have mentioned the same version above
and then install the mysqlclient:
pip install mysqlclient
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With