-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Silent failure on Windows without python-magic-bin #225
Comments
magic should fail with an exception if it can't find the DLL. Is there something in the environment that's preventing that error from being printed? |
Specifically, this error: https://github.com/ahupp/python-magic/blob/master/magic.py#L211 |
I will do some further digging next time I have access to that machine. |
It fails here Line 189 in 2a755be
At which point dll = "C:\Program Files\Git\usr\bin\msys-magic-1.dll" With python-magic-bin installed dll is "C:\redacted\site-packages\magic\libmagic\libmagic.dll" Wrapping that line in a try except print shows that there's a "OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed" As far as I can see somewhere in python importlib land that causes an interpreter exit.
I can see the error go past
but the interpreter never makes it back to
|
I can't say why that DLL is failing to load, maybe you have a 32-bit install of msys and are running 64-bit python? python-magic could fix this by catching the exception, logging and it moving on to the next DLL. I'm wary though that this would be even less obvious; you didn't get any output from this issue (which is a bug in your application I guess?) and this is even more likely to get lost. Did you figure out why the error wasn't getting reported on startup? |
Only that it seems like import lib converts the exception into a sys.exit |
fwiw it looks like an AMD64 bit dll and it's python definitely reports AMD64 |
Does this happen if you directly call |
It would be surprising if importlib exited. Seems more likely that there's an intermediate module doing something like this: try: And then |
pdb was a good suggestion, I should have thought of that |
Did you step on _gcd_import(), or from the spot farther down in magic.py where we throw? |
I started in magic.py and stepped until it exited |
I just had this issue and it was a pain to have until I stumbled on this post and installed I run Python 3.8.5 64 bit on Windows where it crashed with a segfault. On Pypy 3.7.4 it instead failed gracefully with |
also often I need to uninstall and reinstall python-magic-bin, this tends to be necessary around other version updates |
I haven't had time to look into that part of it, but it seems like it's critical that python-magic-bin is installed after python-magic, so if python-magic gets updated it becomes necessary to uninstall and reinstall python-magic-bin |
Merging into #293 |
When I
import magic
the Python process immediately exits with status 9 without printing any error message.This is due to problems in my environment and I don't mind that it didn't work, the problem is how it failed.
I'm trying to bring up an existing Django project on a new machine. I have
python-magic 0.4.18
Python 3.8.6 64bit
Windows 10.0.19041
and I'm running inside the bash/cygwin environment that came with Git for Windows 2.21.0.windows.1
Critically I did not have python-magic-bin installed.
When I
import magic
the Python process immediately exits with status 9 without printing any error message.Of course that import was buried down in some random python file and tracing my silent failure back to python-magic took hours.
The text was updated successfully, but these errors were encountered: