Python mysqlclient install error

Python 3.7, Failed building wheel for MySql-Python

I am new to python and I am trying django framework that involves some MySql and ran into this error when try to do pip install mysqlclient and down the lines of cmd messages I got this.

 Failed building wheel for mysqlclient Running setup.py clean for mysqlclient Failed to build mysqlclient Installing collected packages: mysqlclient Running setup.py install for mysqlclient . error Complete output from command c:\users\ronanl~1\envs\py1\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\RONANL~1\\AppData\\Local\\Temp\\pip-install-pkbqy3t3\\mysqlclient\\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\RONANL~1\AppData\Local\Temp\pip-record-moxwf7lu\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\ronanl~1\envs\py1\include\site\python3.7\mysqlclient: running install running build running build_py creating build creating build\lib.win32-3.7 copying _mysql_exceptions.py -> build\lib.win32-3.7 creating build\lib.win32-3.7\MySQLdb copying MySQLdb\__init__.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\constants 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\constants copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.7\MySQLdb\constants copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.7\MySQLdb\constants running build_ext building '_mysql' extension creating build\temp.win32-3.7 creating build\temp.win32-3.7\Release C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,3,13,'final',0) -D__version__=1.3.13 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" "-Ic:\users\ronan lina\appdata\local\programs\python\python37-32\include" "-Ic:\users\ronan lina\appdata\local\programs\python\python37-32\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.14.26428\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tc_mysql.c /Fobuild\temp.win32-3.7\Release\_mysql.obj /Zl _mysql.c _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\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2 > > > Command "c:\users\ronanl~1\envs\py1\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\RONANL~1\\AppData\\Local\\Temp\\pip-install-pkbqy3t3\\mysqlclient\\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\RONANL~1\AppData\Local\Temp\pip-record-moxwf7lu\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\ronanl~1\envs\py1\include\site\python3.7\mysqlclient" failed with error code 1 in C:\Users\RONANL~1\AppData\Local\Temp\pip-install-pkbqy3t3\mysqlclient\ 

Источник

Читайте также:  Файл configuration php joomla

why ‘pip install mysqlclient’ not working in ubuntu 18.04 LTS

I have just created a virtual environment on my machine (I am running on ubuntu 18.04 LTS). I have the python version of 3.6.7 and now I want to install mysqlclient into my virtual environment. After I do pip install mysqlclient it didn’t work, instead it gave me errors saying;

Command «python.py egg_info» failed with error code 1 in /tmp/pip-install-zd21vfb3/mysqlclient/’, and that the msql_config file is not found.

Looks like the system doesn’t have mysql. mysql_config is a system config file relating to the local mysql server.

4 Answers 4

mysqlclient has a dependency on the mysql client & dev packages being installed. In order to fix this on ubuntu, you have to use apt-get to install a couple of mysql packages.

In your case, it looks like the missing mysql_config might be missing on your system. You can fix that by installing libmysqlclient-dev on ubuntu bionic.

In order to correctly install MySQLClient on a fresh Ubuntu 18.04 LTS you need to install each of the following:

# Replace python3.6 with which ever version of Python3 you are using sudo apt-get install python3.6-dev sudo apt-get install mysql-client sudo apt-get install libmysqlclient-dev sudo apt-get install libssl-dev 

The last one is often missed on answers but is required now.

Only then can you install it via pip. Also make sure to update pip so you are not using version 9 if that installs into your vevn.

Источник

failed pip install mysqlclient on ubuntu 20.04 with python 3.10

I am trying to install mysqlclient with pip but it keeps giving me error message, I already have the development from sudo apt-get install python3-dev default-libmysqlclient-dev build-essential , or use this step : LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient , and this sudo apt-get install libmariadb-dev-compat libmariadb-dev libssl-dev and in the end i always get this : Building wheel for mysqlclient (setup.py) . error error: subprocess-exited-with-error , i use python ver 3.10.4 as main, but i have another version (2.7.18, 3.8.10 and 3.9.5), if i try to download pip install mysqlclient using anaconda, will it cause other problems because i already have python? this is my whole output

Collecting mysqlclient Using cached mysqlclient-2.1.0.tar.gz (87 kB) Preparing metadata (setup.py) . done Building wheels for collected packages: mysqlclient Building wheel for mysqlclient (setup.py) . error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [44 lines of output] mysql_config --version ['10.4.24'] mysql_config --libs ['-L/opt/lampp/lib/', '-lmariadb'] mysql_config --cflags ['-I/opt/lampp/include/mysql', '-I/opt/lampp/include/mysql/mysql'] ext_options: library_dirs: ['/opt/lampp/lib/'] libraries: ['mariadb'] extra_compile_args: ['-std=c99'] extra_link_args: [] include_dirs: ['/opt/lampp/include/mysql', '/opt/lampp/include/mysql/mysql'] extra_objects: [] define_macros: [('version_info', "(2,1,0,'final',0)"), ('__version__', '2.1.0')] running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-cpython-310 creating build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/release.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/times.py -> build/lib.linux-x86_64-cpython-310/MySQLdb creating build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.linux-x86_64-cpython-310 creating build/temp.linux-x86_64-cpython-310/MySQLdb x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Dversion_info=(2,1,0,'final',0) -D__version__=2.1.0 -I/opt/lampp/include/mysql -I/opt/lampp/include/mysql/mysql -I/home/aqila/venv/include -I/usr/include/python3.10 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-310/MySQLdb/_mysql.o -std=c99 MySQLdb/_mysql.c:29:10: fatal error: mysql.h: No such file or directory 29 | #include "mysql.h" | ^~~~~~~~~ compilation terminated. error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for mysqlclient Running setup.py clean for mysqlclient Failed to build mysqlclient Installing collected packages: mysqlclient Running setup.py install for mysqlclient . error error: subprocess-exited-with-error × Running setup.py install for mysqlclient did not run successfully. │ exit code: 1 ╰─> [46 lines of output] mysql_config --version ['10.4.24'] mysql_config --libs ['-L/opt/lampp/lib/', '-lmariadb'] mysql_config --cflags ['-I/opt/lampp/include/mysql', '-I/opt/lampp/include/mysql/mysql'] ext_options: library_dirs: ['/opt/lampp/lib/'] libraries: ['mariadb'] extra_compile_args: ['-std=c99'] extra_link_args: [] include_dirs: ['/opt/lampp/include/mysql', '/opt/lampp/include/mysql/mysql'] extra_objects: [] define_macros: [('version_info', "(2,1,0,'final',0)"), ('__version__', '2.1.0')] running install /home/aqila/venv/lib/python3.10/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.linux-x86_64-cpython-310 creating build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/release.py -> build/lib.linux-x86_64-cpython-310/MySQLdb copying MySQLdb/times.py -> build/lib.linux-x86_64-cpython-310/MySQLdb creating build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants running build_ext building 'MySQLdb._mysql' extension creating build/temp.linux-x86_64-cpython-310 creating build/temp.linux-x86_64-cpython-310/MySQLdb x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Dversion_info=(2,1,0,'final',0) -D__version__=2.1.0 -I/opt/lampp/include/mysql -I/opt/lampp/include/mysql/mysql -I/home/aqila/venv/include -I/usr/include/python3.10 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-310/MySQLdb/_mysql.o -std=c99 MySQLdb/_mysql.c:29:10: fatal error: mysql.h: No such file or directory 29 | #include "mysql.h" | ^~~~~~~~~ compilation terminated. error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1 [end of output] 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.``` 

Источник

Оцените статью