Despite following the readme for the module, I continue to get "magic files not found". The readme and "Dependencies" section say:
On Windows, copy magic1.dll, regex2.dll, and zlib1.dll onto your PATH from the Binaries and Dependencies zip files provided by the File for Windows project. You will need to copy the file magic out of [binary-zip]\share\misc, and pass it's location to Magic(magic_file=...) If you are using a 64-bit build of python, you'll need 64-bit libmagic binaries which can be found here: https://github.com/pidydx/libmagicwin64 (note: untested).
The following clarifications would be helpful:
1) The Files for Windows link provided has a link to "file-5.03-bin.zip" (labeled "Binaries"), a link to "file-5.03-dep.zip" (labeled "Dependencies"), and a link on the bottom right to "file-4.26-dep.zip", which is also labelled "dependencies file". I am assuming that the last is an error, which should point to 5.03-dep, rather than another second dependencies file which is required. Correct?
2) There appears to be a 32 bit version and a 64 bit version of the dependencies files. I don't know which version to use with 64-bit Windows but 32-bit Python. The instructions above say 64 bit Python, but this says 64 bit Windows. Which should I install?
3) The above says to put the DLLs in the PATH; the 64-bit instructions says to put them in C:\Windows\System32. Does it matter, as long as the folder is PATH'd? (Someone else suggested that specifically NOT putting them in \Windows\System32 helped: Python-magic installation error - ImportError: failed to find libmagic).
4) The above suggests that the only other file needed in the binaries and dependencies, other than the 3 DLLs, is the file magic
. So I don't also need the file magic.mgc
, which is also in the binary zip\share\misc? Nor do I need any of the other files in these two ZIPs, like the file file
?
5) The above suggests to get the file magic
out of the binary ZIP and put its path in a line of code which says: Magic(magic_file=...)
. I assume this is actually magic.Magic(magic_file='C:\path\goes\here\magic')
AND I assume this can go anywhere in the file system.
6) .. and I assume, again, I'm pointing to the file magic
rather than the file magic.mgc
.
Are these assumptions correct?
It is recommended to install the latest version of Python, which is 3.7.3 at the time of writing this article.
The current stable version of python-magic is available on PyPI and can be installed by running pip install python-magic . Other sources: PyPI: http://pypi.python.org/pypi/python-magic/ GitHub: https://github.com/ahupp/python-magic.
python-import-magic packageImport automatically python modules using importmagic and then sort using isort. Default keybinding for file auto import Ctrl-Shift-Space . This package also provides an autocomplete provider to add missing imports from a suggestion list. This package needs python importmagic and isort.
I figured out what I was missing. I'll post it here in case anyone else is going crazy.
pip install python-libmagic
pip install python-magic-bin
Install Visual C (VCforPython.msi from [Microsoft website][1])
1) Yes, I think you should download 5.03. Not 4.26.
2) If you have 32-bit python, then download the 32-bit stuff.
3) As long as the dlls are in the system PATH variable, you are fine.
4) Yes. I think you are right.
5) I think that this is true.
6) they are completely different files. magic seems like the correct one because it seems to contain settings and information about what the magic should do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With