Skip to content

ImportError: failed to find libmagic. Check your installation #145

Description

@CarlGalloy

Hi.
In dependency section mention that "magic1.dll, regex2.dll, and zlib1.dll onto your PATH from the Binaries " where exactly PATH is? ( System Environment PATH? )

Activity

  1. ahupp commented on Oct 3, 2017

    @ahupp
    Owner

    Yes, your %PATH% environment variable.

  2. CarlGalloy commented on Oct 6, 2017

    @CarlGalloy
    Author

    Now i have this Error:

    ``

    import magic
    Traceback (most recent call last):
    File "", line 1, in
    File "C:\Python27\lib\site-packages\magic.py", line 154, in
    libmagic = ctypes.CDLL(dll)
    File "C:\Python27\lib\ctypes_init_.py", line 353, in init
    self._handle = _dlopen(self._name, mode)
    WindowsError: [Error 126] The specified module could not be found
    ``

    I install python-magic using pip install magic-python and i can see files on pythonsite-packages installation directory.

    What's wrong?
    and a question: : we must pass location of magic file (from [binary-zip]\share\misc ) to Magic(magic_file=...) ? Like this below code?

    f = magic.Magic(mime=True, uncompress=True,magic_file="./mymagicfile/magic")

  3. ahupp commented on Oct 6, 2017

    @ahupp
    Owner

    No, the magic_file argument won't help here. It's failing to load the libmagic dll for some reason. I generally like to use the "Process Monitor" utility from sysinternals to figure out where it's trying to load DLLs from. Either it's looking in the wrong place, or there's a missing dependency of those dlls.

  4. Ayla93 commented on Oct 23, 2017

    @Ayla93

    Is the problem solved?

  5. ahupp commented on Oct 23, 2017

    @ahupp
    Owner

    @Ayla93: to be clear, this is a local install issue rather than a bug in the library. Are you seeing the same issue as @CarlGalloy ?

  6. theirfanirfi commented on Nov 28, 2017

    @theirfanirfi

    Where is the magic1.DLL and regex located in windows 10. I'm having the same import error.
    Please help me out.

  7. ahupp commented on Dec 4, 2017

    @ahupp
    Owner

    Those are 3rd party libraries you'll have to install. The README file includes some pointers to them, and I've updated it with more info.

  8. ysinjab commented on Mar 18, 2018

    @ysinjab

    For me i faced this issue when I import magic library in my django application. I solved it by " brew install libmagic" installing libmagic on the system level

  9. ashishnitinpatil commented on Apr 2, 2020

    @ashishnitinpatil

    I had this issue with official python docker (python:3.7-slim-buster), so I fixed it with apt-get install libmagic-dev.

  10. jppg commented on Aug 12, 2020

    @jppg

    I solve this problem with "pip install python-magic-bin"

  11. ye commented on Feb 15, 2022

    @ye

    Yep, @ashishnitinpatil your comment was very helpful. The official python docker images is missing the (libmagic-dev for Debian based distro, headers, aka dynamic libraries files etc.), so we need to install libmagic-dev to make it work during the runtime (magic checks the dynamic libs). Alternatively, include the python-magic-bin version which includes those required files.

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