python-magic
python-magic copied to clipboard
MagicException : File 5.39 supports only version 16 magic file, magic.mgc is version 14
I'm getting this error of Magic version on my Virtual Environment when I run python3.8 manage.py migrate on my Django REST API.
I've already done the following after activating Virtual Environment:
pip3 install python-magic --upgrade Here is what exactly is shown at the very end.
magic.MagicException: b"File 5.39 supports only version 16 magic files.`myproject/misc/magic.mgc' is version 14>
Here is the detailed error log.
myproject_common/misc/magic.mgc, 2607: Warning: offset [' invalid myproject_common/misc/magic.mgc, 2608: Warning: offset [' invalid
myproject_common/misc/magic.mgc, 2617: Warning: offset .' invalid myproject_common/misc/magic.mgc, 2619: Warning: offset .' invalid
myproject_common/misc/magic.mgc, 2635: Warning: offset ' invalid myproject_common/misc/magic.mgc, 2653: Warning: offset .' invalid
Traceback (most recent call last):
File "manage.py", line 22, in
This error comes from the underlying libmagic rather than python-magic. It looks like there's a mismatch between your magic definitions file (the magic.mgc mentioned in the errors) and the version of libmagic installed in the container. If you do need your own copy of magic.mgc (why?), you'll need to downgrade libmagic. Alternatively, get rid of your copy of magic.mgc and use the distro-provided version.
Thanks for the assist. I'll do ghe above and come back with results
Hello. I deleted the magic.mgc in the project folder (5484 kb) and replaced it with the one in the Ubuntu root folder(7080 kb). Hope I'm it right ? Is there anything else i need to do ?
If you change this line:
magic.Magic(magic_file='myproject_common/misc/magic.mgc', mime=True)
To remove the magic_file argument:
magic.Magic(mime=True)
It should Just Work, using the mgc file provided by the distro. With the added benefit that you don't run into this problem again next time it upgrades.
Hello. The error isn;'t there but the following error has appeared django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1:3307' (111)")
Is it related to Magic ?
That's not related to libmagic or python-magic
On Sun, May 29, 2022, 8:50 PM Narayanan @.***> wrote:
Hello. The error isn;'t there but the following error has appeared django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '127.0.0.1:3307' (111)")
Is it related to Magic ?
— Reply to this email directly, view it on GitHub https://github.com/ahupp/python-magic/issues/269#issuecomment-1140662011, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAJ5EWL3FIPBJDRP3UBMT3VMQ3GRANCNFSM5XGCMSEQ . You are receiving this because you commented.Message ID: @.***>
This is a local libmagic install issue, closing.