Introducción al problema:
Requiero instalar la librería libmagic, de Python, para un proyecto...
Anteriormente ejecute "pip install libmagic" pero no fue lo que requería ya que al correr el script saltaba este error de importación:
File "c:\users\matii\appdata\local\programs\python\python38-32\lib\site-packages\magic\loader.py", line 39, in load_lib
raise ImportError('failed to find libmagic. Check your installation')
ImportError: failed to find libmagic. Check your installation
Por esto creo que debo instalar la libreria mediante "pip install python-libmagic"...
Cuando intento instalarla mediante: "pip install python-libmagic" salta un error. El origen de este, es que para la instalación se requiere el modulo cffi en su versión 1.7.0 y no la versión actual(cffi-1.15.0), esto se debe a que la ultima actualización de la librería libmagic fue en "jul 7, 2016", fecha en la que lanzo el modulo cffi-1.7.0...
Problema:
El problema real surge al intentar descargar el modulo cffi en su version 1.7.0 mediante el comando: "pip install cffi==1.7.0"
Adjunto el error arrojado desde la cmd al ejecutar el comando "pip install cffi==1.7.0":
Collecting cffi==1.7.0
Using cached cffi-1.7.0.tar.gz (400 kB)
Requirement already satisfied: pycparser in c:\users\matii\appdata\local\programs\python\python38-
32\lib\site-packages (from cffi==1.7.0) (2.20)
Building wheels for collected packages: cffi
Building wheel for cffi (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\matii\appdata\local\programs\python\python38-32\python.exe' -u -c
'import sys, setuptools, tokenize; sys.argv[0] =
'"'"'C:\\Users\\Matii\\AppData\\Local\\Temp\\pip-install-
2ei29j1u\\cffi_dd5f42699429433f96b88e07181c1a66\\setup.py'"'"';
__file__='"'"'C:\\Users\\Matii\\AppData\\Local\\Temp\\pip-install-
2ei29j1u\\cffi_dd5f42699429433f96b88e07181c1a66\\setup.py'"'"';f=getattr(tokenize,
'"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d
'C:\Users\Matii\AppData\Local\Temp\pip-wheel-so6qnh8n'
cwd: C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\
Complete output (45 lines):
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win32-3.8
creating build\lib.win32-3.8\cffi
copying cffi\api.py -> build\lib.win32-3.8\cffi
copying cffi\backend_ctypes.py -> build\lib.win32-3.8\cffi
copying cffi\cffi_opcode.py -> build\lib.win32-3.8\cffi
copying cffi\commontypes.py -> build\lib.win32-3.8\cffi
copying cffi\cparser.py -> build\lib.win32-3.8\cffi
copying cffi\ffiplatform.py -> build\lib.win32-3.8\cffi
copying cffi\lock.py -> build\lib.win32-3.8\cffi
copying cffi\model.py -> build\lib.win32-3.8\cffi
copying cffi\recompiler.py -> build\lib.win32-3.8\cffi
copying cffi\setuptools_ext.py -> build\lib.win32-3.8\cffi
copying cffi\vengine_cpy.py -> build\lib.win32-3.8\cffi
copying cffi\vengine_gen.py -> build\lib.win32-3.8\cffi
copying cffi\verifier.py -> build\lib.win32-3.8\cffi
copying cffi\__init__.py -> build\lib.win32-3.8\cffi
copying cffi\_cffi_include.h -> build\lib.win32-3.8\cffi
copying cffi\parse_c_type.h -> build\lib.win32-3.8\cffi
copying cffi\_embedding.h -> build\lib.win32-3.8\cffi
running build_ext
building '_cffi_backend' extension
creating build\temp.win32-3.8
creating build\temp.win32-3.8\Release
creating build\temp.win32-3.8\Release\c
creating build\temp.win32-3.8\Release\c\libffi_msvc
C:\Program Files (x86)\Microsoft Visual
Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL
/DNDEBUG /MD -Ic/libffi_msvc -Ic:\users\matii\appdata\local\programs\python\python38-32\include
-Ic:\users\matii\appdata\local\programs\python\python38-32\include "-IC:\Program Files
(x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\ATLMFC\include" "-
IC:\Program Files (x86)\Microsoft Visual
Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\include" "-IC:\Program Files (x86)\Windows
Kits\NETFXSDK\4.8\include\um" "-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" /Tcc/_cffi_backend.c /Fobuild\temp.win32-
3.8\Release\c/_cffi_backend.obj
_cffi_backend.c
C:\Users\Matii\AppData\Local\Temp\pip-install-
2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\minibuffer.h(66): warning C4996:
'PyObject_AsReadBuffer': deprecated in 3.0
C:\Users\Matii\AppData\Local\Temp\pip-install-
2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\file_emulator.h(54): warning C4090: '=':
distintos calificadores 'const'
c/_cffi_backend.c(4251): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
c/_cffi_backend.c(4283): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
c/_cffi_backend.c(4353): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
C:\Users\Matii\AppData\Local\Temp\pip-install-
2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\ffi_obj.c(191): warning C4090:
'inicializando': distintos calificadores 'const'
C:\Users\Matii\AppData\Local\Temp\pip-install-
2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\lib_obj.c(129): warning C4090:
'inicializando': distintos calificadores 'const'
C:\Users\Matii\AppData\Local\Temp\pip-install-
2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\lib_obj.c(208): warning C4090:
'inicializando': distintos calificadores 'const'
C:\Users\Matii\AppData\Local\Temp\pip-install-
2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\lib_obj.c(506): warning C4090: '=':
distintos calificadores 'const'
C:\Users\Matii\AppData\Local\Temp\pip-install-
2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\call_python.c(20): error C2037: a la
izquierda de 'builtins' se especifica '_is' struct/union sin definir
C:\Users\Matii\AppData\Local\Temp\pip-install-
2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\call_python.c(73): warning C4090: '=':
distintos calificador es 'const'
C:\Users\Matii\AppData\Local\Temp\pip-install-
2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\call_python.c(160): error C2037: a la
izquierda de 'modules' se especifica '_is' struct/union sin definir
C:\Users\Matii\AppData\Local\Temp\pip-install-
2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\call_python.c(235): error C2037: a la
izquierda de 'modules' se especifica '_is' struct/union sin definir
error: command 'C:\\Program Files (x86)\\Microsoft Visual
Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX86\\x86\\cl.exe' failed
with exit status 2
----------------------------------------
ERROR: Failed building wheel for cffi
Adjunto continuacion del error...:
Running setup.py clean for cffi
Failed to build cffi
Installing collected packages: cffi
Attempting uninstall: cffi
Found existing installation: cffi 1.14.5
Uninstalling cffi-1.14.5:
Successfully uninstalled cffi-1.14.5
Running setup.py install for cffi ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\matii\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Matii\\AppData\\Local\\Temp\\pip-install-2ei29j1u\\cffi_dd5f42699429433f96b88e07181c1a66\\setup.py'"'"'; __file__='"'"'C:\\Users\\Matii\\AppData\\Local\\Temp\\pip-install-2ei29j1u\\cffi_dd5f42699429433f96b88e07181c1a66\\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\Matii\AppData\Local\Temp\pip-record-c1yijq_x\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\matii\appdata\local\programs\python\python38-32\Include\cffi'
cwd: C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\
Complete output (45 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.8
creating build\lib.win32-3.8\cffi
copying cffi\api.py -> build\lib.win32-3.8\cffi
copying cffi\backend_ctypes.py -> build\lib.win32-3.8\cffi
copying cffi\cffi_opcode.py -> build\lib.win32-3.8\cffi
copying cffi\commontypes.py -> build\lib.win32-3.8\cffi
copying cffi\cparser.py -> build\lib.win32-3.8\cffi
copying cffi\ffiplatform.py -> build\lib.win32-3.8\cffi
copying cffi\lock.py -> build\lib.win32-3.8\cffi
copying cffi\model.py -> build\lib.win32-3.8\cffi
copying cffi\recompiler.py -> build\lib.win32-3.8\cffi
copying cffi\setuptools_ext.py -> build\lib.win32-3.8\cffi
copying cffi\vengine_cpy.py -> build\lib.win32-3.8\cffi
copying cffi\vengine_gen.py -> build\lib.win32-3.8\cffi
copying cffi\verifier.py -> build\lib.win32-3.8\cffi
copying cffi\__init__.py -> build\lib.win32-3.8\cffi
copying cffi\_cffi_include.h -> build\lib.win32-3.8\cffi
copying cffi\parse_c_type.h -> build\lib.win32-3.8\cffi
copying cffi\_embedding.h -> build\lib.win32-3.8\cffi
running build_ext
building '_cffi_backend' extension
creating build\temp.win32-3.8
creating build\temp.win32-3.8\Release
creating build\temp.win32-3.8\Release\c
creating build\temp.win32-3.8\Release\c\libffi_msvc
C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Ic/libffi_msvc -Ic:\users\matii\appdata\local\programs\python\python38-32\include -Ic:\users\matii\appdata\local\programs\python\python38-32\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\ATLMFC\include" "-IC:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.28.29910\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" "-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" /Tcc/_cffi_backend.c /Fobuild\temp.win32-3.8\Release\c/_cffi_backend.obj
_cffi_backend.c
C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\minibuffer.h(66): warning C4996: 'PyObject_AsReadBuffer': deprecated in 3.0
C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\file_emulator.h(54): warning C4090: '=': distintos calificadores 'const'
c/_cffi_backend.c(4251): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
c/_cffi_backend.c(4283): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
c/_cffi_backend.c(4353): warning C4996: 'PyUnicode_GetSize': deprecated in 3.3
C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\ffi_obj.c(191): warning C4090: 'inicializando': distintos calificadores 'const'
C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\lib_obj.c(129): warning C4090: 'inicializando': distintos calificadores 'const'
C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\lib_obj.c(208): warning C4090: 'inicializando': distintos calificadores 'const'
C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\lib_obj.c(506): warning C4090: '=': distintos calificadores 'const'
C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\call_python.c(20): error C2037: a la izquierda de 'builtins' se especifica '_is' struct/union sin definir
C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\call_python.c(73): warning C4090: '=': distintos calificadores 'const'
C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\call_python.c(160): error C2037: a la izquierda de 'modules' se especifica '_is' struct/union sin definir
C:\Users\Matii\AppData\Local\Temp\pip-install-2ei29j1u\cffi_dd5f42699429433f96b88e07181c1a66\c\call_python.c(235): error C2037: a la izquierda de 'modules' se especifica '_is' struct/union sin definir
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.28.29910\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
----------------------------------------
Rolling back uninstall of cffi
Moving to c:\users\matii\appdata\local\programs\python\python38-32\lib\site-
packages\_cffi_backend.cp38-win32.pyd
from C:\Users\Matii\AppData\Local\Temp\pip-uninstall-bnzpqw4o\_cffi_backend.cp38-win32.pyd
Moving to c:\users\matii\appdata\local\programs\python\python38-32\lib\site-packages\cffi-
1.14.5.dist-info\
from C:\Users\Matii\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\~ffi-1.14.5.dist-
info
Moving to c:\users\matii\appdata\local\programs\python\python38-32\lib\site-packages\cffi\
from C:\Users\Matii\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\~ffi
ERROR: Command errored out with exit status 1:
'c:\users\matii\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys,
setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Matii\\AppData\\Local\\Temp\\pip-install-
2ei29j1u\\cffi_dd5f42699429433f96b88e07181c1a66\\setup.py'"'"';
__file__='"'"'C:\\Users\\Matii\\AppData\\Local\\Temp\\pip-install-
2ei29j1u\\cffi_dd5f42699429433f96b88e07181c1a66\\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\Matii\AppData\Local\Temp\pip-record-
c1yijq_x\install-record.txt' --single-version-externally-managed --compile --install-headers
'c:\users\matii\appdata\local\programs\python\python38-32\Include\cffi' Check the logs for full
command output.
Para intentar solucionar este problema he intentado lo siguiente:
- Descargar e instalar el modulo cffi-1.7.0 mediante "pip install cffi-1.7.0.tar.gz" (Descargando el archivo desde "https://pypi.org/project/cffi/1.7.0/#files")
- Descargar e instalar la librería libmagic-0.4.0 mediante "pip install python-libmagic-0.4.0.tar.gz" (Descargando el archivo desde "https://pypi.org/project/python-libmagic/#files")
- Actualizar setuptools "pip install -U setuptools"
- Actualizar pip "python -m pip install --upgrade pip"
- Instalar "Herramientas de compilación de C++" mediante "Visual Studio Build Tools 2019"
Como era de esperarse, el realizar estos pasos, no soluciono mi problema...
¿De que forma puedo solucionar este problema?
Info adicional:
Python: "3.8.3"(versión)
SO: Windows 10pro
pip install python-magic
pip install python-magic-bin
? Leí algunos Issues en GitHub, de otros módulos, y resolvían con la segunda opción. Slds