1

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.41 supports only version 16 magic files.`myproject/misc/magic.mgc' is version 14>

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 <module>
    execute_from_command_line(sys.argv)
  File "/home/earthling/myEnv/lib/python3.8/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/earthling/myEnv/lib/python3.8/site-packages/django/core/management/__init__.py", line 357, in execute
    django.setup()
  File "/home/earthling/myEnv/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/earthling/myEnv/lib/python3.8/site-packages/django/apps/registry.py", line 114, in populate
    app_config.import_models()
  File "/home/earthling/myEnv/lib/python3.8/site-packages/django/apps/config.py", line 211, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/earthling/myprojects/MyAPI/myproject_auth/models.py", line 31, in <module>
    from myproject_common.utils.helpers import delete_file_field
  File "/home/earthling/myprojects/MyAPI/myproject_common/utils/helpers.py", line 131, in <module>
    magic = magic.Magic(magic_file='myproject_common/misc/magic.mgc', mime=True)
  File "/home/earthling/myEnv/lib/python3.8/site-packages/magic.py", line 66, in __init__
    magic_load(self.cookie, magic_file)
  File "/home/earthling/myEnv/lib/python3.8/site-packages/magic.py", line 291, in magic_load
    return _magic_load(cookie, coerce_filename(filename))
  File "/home/earthling/myEnv/lib/python3.8/site-packages/magic.py", line 217, in errorcheck_negative_one
    raise MagicException(err)
magic.MagicException: b"File 5.41 supports only version 16 magic files. `myproject_common/misc/magic.mgc' is version 14"

There are several line of errors like the offset error but I have taken a few of them and posted it due to character limitations on stack.

Need help here since I'm stuck and unable to proceed ahead.

Earthling
  • 83
  • 3
  • 13
  • Are you using python3.8 when run django project? – Metalgear May 27 '22 at 06:48
  • python3.8 manage.py migrate is the command im using – Earthling May 27 '22 at 09:29
  • @David. Tag anyone who could help ? – Earthling May 27 '22 at 13:17
  • I've tried downgrading python-magic to older versions but to no effect on the error. – Earthling May 27 '22 at 13:27
  • @David this is to do with the following package which has issues with magic.mgc https://archlinux.org/packages/core/x86_64/file/ . However i cant seem to solve the issue yet. – Earthling May 28 '22 at 06:50
  • @David, I don't have enough reputation to comment on others post. Here is a related issue related to magic.mgc https://stackoverflow.com/questions/47683615/file-command-error-how-to-update-magic-file – Earthling May 28 '22 at 12:26
  • Hey @Earthling, have you been able to solve this issue? I have the very same issue at the moment, my error message looks something like this : ```magic.magic.MagicException: b"File 5.39 supports only version 16 magic files. `/usr/local/lib/python3.7/site-packages/magic/libmagic/magic.mgc' is version 14"``` – Saurav Saha Aug 05 '22 at 10:52

0 Answers0