Skip to content

Instantly share code, notes, and snippets.

@abakum
Created March 4, 2019 12:53
Show Gist options
  • Save abakum/c08e611e41c872256bb39a169abd7e92 to your computer and use it in GitHub Desktop.
Save abakum/c08e611e41c872256bb39a169abd7e92 to your computer and use it in GitHub Desktop.
Fix error "raise ImportError('failed to find libmagic. Check your installation')" after "pip install python-magic" then "import magic" in python of MINGW
mklink "C:\msys64\usr\bin\magic1.dll" "C:\msys64\usr\bin\msys-magic-1.dll"
@abakum
Copy link
Author

abakum commented Mar 5, 2019

  1. Install msys2:
    choco install msys2
  2. Install tools:
    msys2.exe
    pacman -S git --needed
    pacman -S base-devel --needed
    exit
    mingw64.exe
    pacman -S $MINGW_PACKAGE_PREFIX-toolchain --needed
  3. Build libmagic:
    git clone https://github.com/threatstack/libmagic.git
    cd libmagic
    ./configure
    make
    make install
  4. Test file
    file -v
    Look:
    C:\msys64\mingw64\bin\file.exe-5.18
    magic file from C:\msys64\mingw64\bin/../share/misc/magic.mgc
  5. Make link for python-magic:
    ln -s /mingw64/bin/libmagic-1.dll /mingw64/bin/magic1.dll

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment