Exception Value:failed to find libmagic. Check your installation in windows 7

前端 未结 5 1826
不知归路
不知归路 2021-02-05 04:48

When I am trying to open django admin panel this error is showing:

ImportError at /admin/
failed to find libmagic.  Check your installation
Request Method: GET
R         


        
5条回答
  •  囚心锁ツ
    2021-02-05 05:08

    As per the documentation the current version of python-magic is 0.4.15

    • You can install the latest released version of python-magic through:

      pip install python-magic
      
    • This will install python-magic-0.4.15 as follows:

      C:\Users\username>pip install python-magic
      Collecting python-magic
        Using cached https://files.pythonhosted.org/packages/42/a1/76d30c79992e3750dac6790ce16f056f870d368ba142f83f75f694d93001/python_magic-0.4.15-py2.py3-none-any.whl
      Installing collected packages: python-magic
      Successfully installed python-magic-0.4.15
      
    • In the (Windows) documentation it is mentioned:

    You'll need DLLs for libmagic. @julian-r has uploaded a version of this project that includes binaries to pypi: https://pypi.python.org/pypi/python-magic-bin/0.4.14

    • You can install the python-magic-bin 0.4.14 through:

      pip install python-magic-bin==0.4.14
      
    • This will install python-magic-bin 0.4.14 as follows:

      C:\Users\username>pip install python-magic-bin==0.4.14
      Collecting python-magic-bin==0.4.14
        Downloading https://files.pythonhosted.org/packages/5a/5d/10b9ac745d9fd2f7151a2ab901e6bb6983dbd70e87c71111f54859d1ca2e
      /python_magic_bin-0.4.14-py2.py3-none-win32.whl (397kB)
          100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 399kB 473kB/s
      Installing collected packages: python-magic-bin
      Successfully installed python-magic-bin-0.4.14
      
    • Sample Code:

      import magic
      print(magic.from_file("C:/Users/username/Desktop/StackOverflow/Google_Gmail.png"))
      
    • Console Output:

      PNG image data, 1366 x 768, 8-bit/color RGB, non-interlaced
      

提交回复
热议问题