failed to find libmagic

I am trying to setup an existing project in Django 2.2 on Windows 10 Python 3.8.
I tried doing py .\manage.py runserver but it complained that libmagic wasn’t there, so I installed it but it’s still complaining.

(virt-env) PS E:\workspace\project1> pip.exe install libmagic
Collecting libmagic
  Downloading libmagic-1.0.tar.gz (3.7 kB)
Using legacy 'setup.py install' for libmagic, since package 'wheel' is not installed.
Installing collected packages: libmagic
    Running setup.py install for libmagic ... done
Successfully installed libmagic-1.0
WARNING: You are using pip version 20.2.3; however, version 21.2.4 is available.
You should consider upgrading via the 'e:\workspace\project1\project1\scripts\python.exe -m pip install --upgrade pip' command.
(virt-env) PS E:\workspace\project1> py .\manage.py runserver
Performing system checks...

Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\username\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\username\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "E:\workspace\project1\project1\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
    fn(*args, **kwargs)
  File "E:\workspace\project1\project1\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "E:\workspace\project1\project1\lib\site-packages\django\core\management\base.py", line 387, in check
    all_issues = self._run_checks(
  File "E:\workspace\project1\project1\lib\site-packages\django\core\management\base.py", line 377, in _run_checks
    return checks.run_checks(**kwargs)
  File "E:\workspace\project1\project1\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "E:\workspace\project1\project1\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "E:\workspace\project1\project1\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "E:\workspace\project1\project1\lib\site-packages\django\urls\resolvers.py", line 399, in check
    for pattern in self.url_patterns:
  File "E:\workspace\project1\project1\lib\site-packages\django\utils\functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "E:\workspace\project1\project1\lib\site-packages\django\urls\resolvers.py", line 584, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "E:\workspace\project1\project1\lib\site-packages\django\utils\functional.py", line 80, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "E:\workspace\project1\project1\lib\site-packages\django\urls\resolvers.py", line 577, in urlconf_module
    return import_module(self.urlconf_name)
  File "C:\Users\username\AppData\Local\Programs\Python\Python38\lib\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 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "E:\workspace\project1\project1\urls.py", line 32, in <module>
    path(r'', include(('static.urls', 'static'), namespace='static')),
  File "E:\workspace\project1\project1\lib\site-packages\django\urls\conf.py", line 34, in include
    urlconf_module = import_module(urlconf_module)
  File "C:\Users\username\AppData\Local\Programs\Python\Python38\lib\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 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "E:\workspace\project1\static\urls.py", line 13, in <module>
    from . import views
  File "E:\workspace\project1\static\views.py", line 23, in <module>
    from .forms import ContactForm, ComplaintContactForm, COVIDRequestForm, CcpaForm, EmailVerifyForm
  File "E:\workspace\project1\static\forms.py", line 8, in <module>
    from application.forms import SUFFIX_CHOICES, STATE_CHOICES, SSNWidget, SSNField, PARTY_TYPE, REQUEST_TYPE
  File "E:\workspace\project1\application\forms.py", line 11, in <module>
    from application.form_config import *
  File "E:\workspace\project1\application\form_config.py", line 12, in <module>
    from utils.miscellaneous import split
  File "E:\workspace\project1\utils\miscellaneous.py", line 18, in <module>
    import magic
  File "E:\workspace\project1\project1\lib\site-packages\magic.py", line 181, in <module>
    raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation

That is an extremely old package (2012)! I’d have no confidence that it’s going to work in a current environment. The link to the homepage on pypi.org isn’t even valid.

My best recommendation is to find another solution for what you’re trying to do.

It exists in requirements.txt = python-magic==0.4.15
This is installed on Ubuntu 20.04 VirtualBox - but I am now trying to get the Django app working on my Windows 10 host.

That is a different package. python-magic is not the same as libmagic, which are both different from python-libmagic.

If you’re installing python-magic, make sure you also install the dependency library as documented on python-magic · PyPI.

Thank You - I had to do pip install python-magic-bin on Windows.