Questions tagged [python-magic]

python-magic is a python interface to the libmagic file type identification library.

python-magic is a python interface to the libmagic file type identification library. libmagic identifies file types by checking their headers according to a predefined list of file types. This functionality is exposed to the command line by the Unix command file.

See https://github.com/ahupp/python-magic

56 questions
1
vote
1 answer

Stop the effect of %matplotlib notebook in Jupyter notebook

I used the magic commands %matplotlib notebook at some ceil in my notebook to animate some scatter plots. However, after that ceil, I want to remove the effect of this magic command. Anyone has any idea of how to do this?
1
vote
1 answer

Python3 Magic for a Django project

I need the python-magic package for a Django project. However, I found out that since I am using python3, I need the python3-magic package, which I can either get using pip3 or using apt-get. I am a macOS user, so I don't have an apt-get, and I…
Panda
  • 19
  • 5
1
vote
0 answers

MagicException : File 5.41 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…
1
vote
1 answer

How to access variables made in __init_subclass__ from __init__?

Here is sample code: from abc import * class weightlayer(metaclass=ABCMeta): def __init_subclass__(cls): cls.count = 0 def __init__(self): self.order = cls.count cls.count += 1 @abstractmethod def…
string
  • 39
  • 4
1
vote
1 answer

How can I use python magic on Heroku as well as local windows machine?

My django project uses python-magic. In order to get magic working on my local windows machine, I've had to install python-magic-bin, otherwise I faced the error "ImportError: failed to find libmagic. Check your installation". But when I push this…
be2213444
  • 607
  • 1
  • 4
  • 10
1
vote
1 answer

File type from pandas.DataFrame.to_excel is "Zip archive data, at least v2.0 to extract"

I notice that the file type from an Excel file generated by pandas.DataFrame.to_excel is Zip archive data, at least v2.0 to extract. Please do note that the content type is fine: content_type,…
1
vote
2 answers

Why is Module python-magic not available?

I am using s3cmd to sync to an S3 bucket from a Mac and I am getting the following warning: WARNING: Module python-magic is not available. Guessing MIME types based on file extensions. But pip list shows that python-magic is in fact…
Mark Fisher
  • 965
  • 1
  • 11
  • 30
1
vote
1 answer

Error in trying to install/use Python-Magic in Google Colab

I am trying to install python-magic in Colab. Here is the Github of the library https://github.com/ahupp/python-magic#dependencies When I try : !pip install python-magic import magic This Results in…
SantoshGupta7
  • 5,607
  • 14
  • 58
  • 116
1
vote
1 answer

Why do I get a TypeError when passing a bytes string to magic.from_buffer()?

I am trying to get the filetype of an image from the url using python-magic's from_buffer, and it works well in practice, but fails when I try to run a unittest. This is my function: def get_uri_from_url(url): if url != '': response =…
Jamie J
  • 1,168
  • 1
  • 9
  • 22
1
vote
1 answer

Django with python-magic (libmagic) to verify uploaded files

I'm trying to save the mime type of an uploaded file in django. I don't need to reject certain types of files, I just need to keep track of the mime type of uploaded files. I'm doing this: class Foo(models.Model): document =…
Alex
  • 2,270
  • 3
  • 33
  • 65
1
vote
1 answer

What should I do to use python-magic on Heroku?

I'm building an application that is using python-magic 0.4.15. On my local machine, python-magic-bin 0.4.15 works like a charm (Windows) but I'm trying to make it work on Heroku. First I'm just trying to get the tests to pass in the Heroku-CI. I…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
1
vote
0 answers

ElastAlert and libmagic

When trying to run ElastAlert via python (per ElastAlert read the docs page) the below is returned. Command: python -m elastalert.elastalert --verbose --rule example_frequency.yaml Error: ImportError: failed to find libmagic. Check your…
Jason
  • 33
  • 4
1
vote
1 answer

Python-magic has OSError: [WinError 193] error while running in 32-bit version of IDLE

I have been trying to install the module python-magic for a few hours, and I've been encountering some problems. I am using the 32-bit version of Python 3.5.2 with 64-bit Windows 7. First, I used the command "pip install python-magic". I downloaded…
raincloud
  • 67
  • 5
1
vote
1 answer

How to get information of .jar file in python-magic

I have a folder full of jar, html, css, exe type file. How can I check the file? I already run "file" command on *NIX and using python-magic. but the result is all like this. test : Zip archive data, at least v1.0 to extract How can I get…
bunseokbot
  • 11
  • 2
1
vote
0 answers

How to Solve MagicException: "could not find any magic files" in s3cmd?

I am using s3cmd to upload files. and it always upload .png file as "image/x-png" for MIME type. So I decide to install "python-magic" What I did here: Installed Python 2.7 x86 on Windows 7 64bit, (since the manual of "python-magic" said only x86…
Eric Yin
  • 8,737
  • 19
  • 77
  • 118