Skip to content

Binary distribution for libmagic on Windows #293

Description

@ahupp

Windows users regularly run into issues with incompatible/broken or not found magic installations. Current issues:

#137
#288
#225
#276
#248
#87
#139
#233
#73
#60
#34

This task is to document/implement a more reliable solution for windows.

Activity

  1. jspraul commented on Sep 5, 2023

    @jspraul

    python-magic-bin v0.4.14 was published in 2017. vcpkg can build libmagic v5.40 (circa 2021) with some tweaks for Windows.

    • Download and install the Visual Studio 2017 Build Tools (link source)

      • On the left, select Windows > Visual C++ build tools
      • Then on the right, confirm Visual C++ tools for CMake is selected
        • (3.3GB+ download since Windows 10 SDK is a dependency 😢)

      image

    • Per https://github.com/microsoft/vcpkg#quick-start-windows:

      • git clone https://github.com/microsoft/vcpkg
      • .\vcpkg\bootstrap-vcpkg.bat
      • .\vcpkg\vcpkg install libmagic --triplet=x64-windows
    • Under .\vcpkg\packages\libmagic_x64-windows (don't use mine) you'll find:

      • tools\libmagic\bin\magic-1.dll
        • python-magic loads libmagic.dll, you'll need to rename to this
      • tools\libmagic\bin\tre.dll
      • tools\libmagic\share\misc\magic.mgc
    • Place these files in the current directory, on the path, or overwrite after pip puts python-magic-bin under \Lib\site-packages\magic\libmagic

      • (in the same directory as the script will only work if that is the current directory or on the path)

    Related: hey-red/Mime#49 | https://github.com/hey-red/Libmagic-Build/tree/master/windows

    Windows build is most problematic part of this

  2. ahupp commented on Oct 10, 2023

    @ahupp
    OwnerAuthor
  3. martin-braun commented on Oct 29, 2024

    @martin-braun

    On Windows #248 is still a problem and automatic monkey patching is not an option when using pipx, because the cache path (virtual environment path) is always random.

  4. flawrist commented on Jun 3, 2025

    @flawrist

    Guys, if you have a working file.exe v5.46 for Windows, please attach it here.
    So far I have managed to find and properly test v5.44 if anyone is looking for it.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions