Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to import "eml_parser" module in Python

I am unable to import "eml_parser" module in Python. I am running Windows 10, Python37 and Anaconda 5.3 (all 64 bit) The installation docs are at this link: https://pypi.org/project/eml-parser/

I did find the following suggestion from https://github.com/pymedusa/Medusa/issues/1843 but I have not tried it yet. To update the init file as suggested requires administrative rights and I wasn't exactly sure how to open the file as an administrator and save it that way. It seem to make more sense to ask the question before getting too far into editing files. Note line 362 in the quote below would be the equivalent to line 356 on my error message.

Suggestion from https://github.com/pymedusa/Medusa/issues/1843 "If you are using a special version of Python [like Anaconda] and you can't fix it. Navigate to line 362 of lib/ctypes/init.py and change it to: self._handle = _dlopen(str(self._name), mode)"

From Command Prompt, I get the following error message:

 >>> import eml_parser
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Program Files\Python37\lib\site-packages\eml_parser\__init__.py", line 8, in <module>
    from . import eml_parser
  File "C:\Program Files\Python37\lib\site-packages\eml_parser\eml_parser.py", line 63, in <module>
    import magic
  File "C:\Program Files\Python37\lib\site-packages\magic.py", line 23, in <module>
    _libraries['magic'] = _init()
  File "C:\Program Files\Python37\lib\site-packages\magic.py", line 20, in _init
    return ctypes.cdll.LoadLibrary(find_library('magic'))
  File "C:\Program Files\Python37\lib\ctypes\__init__.py", line 434, in LoadLibrary
    return self._dlltype(name)
  File "C:\Program Files\Python37\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None
like image 614
Oedipus Avatar asked Mar 10 '26 04:03

Oedipus


1 Answers

Im not sure how it fixes this but I tried

pip install python-magic
pip install eml_parser

And got this working on Windows 10

https://github.com/GOVCERT-LU/eml_parser/issues/14

like image 169
Andres Namm Avatar answered Mar 12 '26 18:03

Andres Namm