@@ -6,7 +6,7 @@ their headers according to a predefined list of file types. This
66functionality is exposed to the command line by the Unix command
77` file ` .
88
9- ## Example Usage
9+ ## Usage
1010
1111 >>> import magic
1212 >>> magic.from_file("testdata/test.pdf")
@@ -16,6 +16,12 @@ functionality is exposed to the command line by the Unix command
1616 >>> magic.from_file("testdata/test.pdf", mime=True)
1717 'application/pdf'
1818
19+ There is also a ` Magic ` class that provides more direct control,
20+ including overriding the magic database file and turning on character
21+ encoding dectection. This is not recommended for general use. In
22+ particular, it its not safe for sharing across multiple threads and
23+ will fail throw if this is attempted.
24+
1925## Installation
2026
2127The current stable version of python-magic is available on pypi and
@@ -35,6 +41,24 @@ On Windows, you need to download and save the following libraries under
3541- ` zlib1.dll ` from [ sourceforge.net/projects/gnuwin32/files/zlib/] ( http://sourceforge.net/projects/gnuwin32/files/zlib/ )
3642- ` magic1.dll ` from [ sourceforge.net/projects/gnuwin32/files/file/] ( http://sourceforge.net/projects/gnuwin32/files/file/ )
3743
44+ On OSX:
45+
46+ - When using Homebrew: ` brew install file-formula `
47+ - When using macports: ` port install file `
48+
49+ ### Troubleshooting
50+
51+ - 'MagicException: could not find any magic files!': some
52+ installations of libmagic do not correctly point to their magic
53+ database file. Try specifying the path to the file explictly in the
54+ constructor: ` magic.Magic(magic_file="path_to_magic_file") ` .
55+
56+ - 'WindowsError: [ Error 193] %1 is not a valid Win32 application':
57+ Attempting to run the 32-bit libmagic DLL in a 64-bit build of
58+ python will fail with this error. I'm not aware of any publically
59+ available 64-bit builds of libmagic. You'll either need to build
60+ them yourself (pleae share docs!), or switch to a 32-bit Python.
61+
3862## Author
3963
4064Written by Adam Hupp in 2001 for a project that never got off the
0 commit comments