Para un proyecto tengo que instalar una versión específica de mysqlclient==1.3.7
sobre Windows. Sin embargo obtengo errores: parece que falta my_config.h
en MSVC (Microsoft Studio Visual C++) que es necesario para esta libreria:
(venv) C:\Users\antoi\Documents\Programming\Work\data-tools>python -m pip install mysqlclient==1.3.7
Collecting mysqlclient==1.3.7
Using cached mysqlclient-1.3.7.tar.gz (79 kB)
Using legacy 'setup.py install' for mysqlclient, since package 'wheel' is not installed.
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] =
'"'"'C:\\Users\\antoi\\AppData\\Local\\Temp\\pip-install-yene8tri\\mysqlclient_80b7a63f4260436e8e27b3d60de6d124\\setup.py'"'"'; __file__='"'"'C:\\Users\\a
ntoi\\AppData\\Local\\Temp\\pip-install-yene8tri\\mysqlclient_80b7a63f4260436e8e27b3d60de6d124\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(_
_file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"'
);f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\antoi\AppData\Local\Temp\pip-record-8eompdh_\install-record.txt' --si
ngle-version-externally-managed --compile --install-headers 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\include\site\python3.9\mysqlclient'
cwd: C:\Users\antoi\AppData\Local\Temp\pip-install-yene8tri\mysqlclient_80b7a63f4260436e8e27b3d60de6d124\
Complete output (34 lines):
C:\Users\antoi\Documents\Programming\Work\data-tools\venv\lib\site-packages\setuptools\dist.py:691: UserWarning: Usage of dash-separated 'distribution-
name' will not be supported in future versions. Please use the underscore name 'distribution_name' instead
warnings.warn(
C:\Users\antoi\Documents\Programming\Work\data-tools\venv\lib\site-packages\setuptools\dist.py:691: UserWarning: Usage of dash-separated 'build-require
s' will not be supported in future versions. Please use the underscore name 'build_requires' instead
warnings.warn(
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.9
copying _mysql_exceptions.py -> build\lib.win-amd64-3.9
creating build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\compat.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-3.9\MySQLdb
creating build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.9\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\Release
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dv
ersion_info=(1,3,7,'final',1) -D__version__=1.3.7 -IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include -IC:\Users\antoi\Documents\Programming\Work\
data-tools\venv\include -IC:\Users\antoi\AppData\Local\Programs\Python\Python39\include -IC:\Users\antoi\AppData\Local\Programs\Python\Python39\include -IC
:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041
.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program
Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /Tc_mysql.c /Fobuild\temp.win
-amd64-3.9\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(29): fatal error C1083: Cannot open include file: 'my_config.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed wit
h exit code 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\Scripts\python.exe' -u -c 'import io, os, sys, se
tuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\antoi\\AppData\\Local\\Temp\\pip-install-yene8tri\\mysqlclient_80b7a63f4260436e8e27b3d60de6d124\\setup.py
'"'"'; __file__='"'"'C:\\Users\\antoi\\AppData\\Local\\Temp\\pip-install-yene8tri\\mysqlclient_80b7a63f4260436e8e27b3d60de6d124\\setup.py'"'"';f = getattr(
tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().rep
lace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\antoi\AppData\Local\Temp\pip-record-
8eompdh_\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\inc
lude\site\python3.9\mysqlclient' Check the logs for full command output.
WARNING: You are using pip version 21.1.2; however, version 21.1.3 is available.
You should consider upgrading via the 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\Scripts\python.exe -m pip install --upgrade pip' command.
Entonces installé wheel
:
(venv) C:\Users\antoi\Documents\Programming\Work\data-tools>python -m pip install wheel
Collecting wheel
Using cached wheel-0.36.2-py2.py3-none-any.whl (35 kB)
Installing collected packages: wheel
Successfully installed wheel-0.36.2
Pero persiste el error:
(venv) C:\Users\antoi\Documents\Programming\Work\data-tools>python -m pip install mysqlclient==1.3.7
Collecting mysqlclient==1.3.7
Using cached mysqlclient-1.3.7.tar.gz (79 kB)
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '
"'"'C:\\Users\\antoi\\AppData\\Local\\Temp\\pip-install-7d7pvf8w\\mysqlclient_9111de6a6ad24be8baf589d2e24b4ee4\\setup.py'"'"'; __file__='"'"'C:\\Users\\ant
oi\\AppData\\Local\\Temp\\pip-install-7d7pvf8w\\mysqlclient_9111de6a6ad24be8baf589d2e24b4ee4\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__f
ile__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');
f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\antoi\AppData\Local\Temp\pip-wheel-4hpf0iea'
cwd: C:\Users\antoi\AppData\Local\Temp\pip-install-7d7pvf8w\mysqlclient_9111de6a6ad24be8baf589d2e24b4ee4\
Complete output (34 lines):
C:\Users\antoi\Documents\Programming\Work\data-tools\venv\lib\site-packages\setuptools\dist.py:691: UserWarning: Usage of dash-separated 'distribution-na
me' will not be supported in future versions. Please use the underscore name 'distribution_name' instead
warnings.warn(
C:\Users\antoi\Documents\Programming\Work\data-tools\venv\lib\site-packages\setuptools\dist.py:691: UserWarning: Usage of dash-separated 'build-requires'
will not be supported in future versions. Please use the underscore name 'build_requires' instead
warnings.warn(
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.9
copying _mysql_exceptions.py -> build\lib.win-amd64-3.9
creating build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\compat.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-3.9\MySQLdb
creating build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.9\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\Release
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dver
sion_info=(1,3,7,'final',1) -D__version__=1.3.7 -IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include -IC:\Users\antoi\Documents\Programming\Work\da
ta-tools\venv\include -IC:\Users\antoi\AppData\Local\Programs\Python\Python39\include -IC:\Users\antoi\AppData\Local\Programs\Python\Python39\include -IC:\
Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0
\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program Fi
les (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /Tc_mysql.c /Fobuild\temp.win-a
md64-3.9\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(29): fatal error C1083: Cannot open include file: 'my_config.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed with
exit code 2
----------------------------------------
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: Command errored out with exit status 1:
command: 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\Scripts\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] =
'"'"'C:\\Users\\antoi\\AppData\\Local\\Temp\\pip-install-7d7pvf8w\\mysqlclient_9111de6a6ad24be8baf589d2e24b4ee4\\setup.py'"'"'; __file__='"'"'C:\\Users\\a
ntoi\\AppData\\Local\\Temp\\pip-install-7d7pvf8w\\mysqlclient_9111de6a6ad24be8baf589d2e24b4ee4\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(_
_file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"'
);f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\antoi\AppData\Local\Temp\pip-record-65kewmz2\install-record.txt' --si
ngle-version-externally-managed --compile --install-headers 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\include\site\python3.9\mysqlclient'
cwd: C:\Users\antoi\AppData\Local\Temp\pip-install-7d7pvf8w\mysqlclient_9111de6a6ad24be8baf589d2e24b4ee4\
Complete output (34 lines):
C:\Users\antoi\Documents\Programming\Work\data-tools\venv\lib\site-packages\setuptools\dist.py:691: UserWarning: Usage of dash-separated 'distribution-
name' will not be supported in future versions. Please use the underscore name 'distribution_name' instead
warnings.warn(
C:\Users\antoi\Documents\Programming\Work\data-tools\venv\lib\site-packages\setuptools\dist.py:691: UserWarning: Usage of dash-separated 'build-require
s' will not be supported in future versions. Please use the underscore name 'build_requires' instead
warnings.warn(
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.9
copying _mysql_exceptions.py -> build\lib.win-amd64-3.9
creating build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\compat.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-3.9\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-3.9\MySQLdb
creating build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.9\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.9\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win-amd64-3.9
creating build\temp.win-amd64-3.9\Release
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dv
ersion_info=(1,3,7,'final',1) -D__version__=1.3.7 -IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include -IC:\Users\antoi\Documents\Programming\Work\
data-tools\venv\include -IC:\Users\antoi\AppData\Local\Programs\Python\Python39\include -IC:\Users\antoi\AppData\Local\Programs\Python\Python39\include -IC
:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30037\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041
.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um -IC:\Program
Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\cppwinrt /Tc_mysql.c /Fobuild\temp.win
-amd64-3.9\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(29): fatal error C1083: Cannot open include file: 'my_config.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.29.30037\\bin\\HostX86\\x64\\cl.exe' failed wit
h exit code 2
----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\Scripts\python.exe' -u -c 'import io, os, sys, se
tuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\antoi\\AppData\\Local\\Temp\\pip-install-7d7pvf8w\\mysqlclient_9111de6a6ad24be8baf589d2e24b4ee4\\setup.py
'"'"'; __file__='"'"'C:\\Users\\antoi\\AppData\\Local\\Temp\\pip-install-7d7pvf8w\\mysqlclient_9111de6a6ad24be8baf589d2e24b4ee4\\setup.py'"'"';f = getattr(
tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().rep
lace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\antoi\AppData\Local\Temp\pip-record-
65kewmz2\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\inc
lude\site\python3.9\mysqlclient' Check the logs for full command output.
WARNING: You are using pip version 21.1.2; however, version 21.1.3 is available.
You should consider upgrading via the 'C:\Users\antoi\Documents\Programming\Work\data-tools\venv\Scripts\python.exe -m pip install --upgrade pip' command.
Aviso
mi experiencia con mysqlclient es un verdadero desastre:
Con Fedora:
- Con la libreria mysqlclient==1.3.7 (celle du serveur Debian):
mysql_config
falta, incluso al reinstalar conectores comomariadb-connector-c-devel
ocommunity-mysql-devel
- Con la libreria 2.0.3: MySQL-python falta, o no se reconoce
Con Windows:
- Avec la librairie mysqlclient==1.3.7 , imposible de instalar: me dice que use Visual C++ pero no cambia nada. Así que he probado con una versión preconstruida del sitio de Christoph Gohlke pero no es compatible. [esta pregunta]
- Con >2.* obtengo:
OperationalError: (2006, '')
en una gran parte de las consultas SQL como la siguiente:
c.execute("""
UPDATE `{table_name}`
SET `{column_name}` = CONCAT('hash_', {expression})
WHERE {pk_name} IN ({ids})
""".format(
table_name=table_name, column_name=column_name, expression=expression, pk_name=pk_name,
ids=','.join(ids)
))