Skip to content
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

Exception on Windows related to default encoding for Python's open #406

Closed
HDembinski opened this issue Dec 2, 2024 · 1 comment
Closed

Comments

@HDembinski
Copy link

I am just trying out marker, I installed the current version from PyPI on my Windows machine.

After it run for a while on a large PDF, I got this exception. The reason is that on Windows, the default encoding is not utf-8. Platform-independent code has to set the encoding explicitly when open is called.

Since this library is so popular, I am baffled that no one stumbled over this before?

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\HansDembinski\AppData\Local\micromamba\envs\dbc_demonstrator\Scripts\marker_single.exe\__main__.py", line 7, in <module>
  File "C:\Users\HansDembinski\AppData\Local\micromamba\envs\dbc_demonstrator\Lib\site-packages\click\core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\HansDembinski\AppData\Local\micromamba\envs\dbc_demonstrator\Lib\site-packages\click\core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "C:\Users\HansDembinski\AppData\Local\micromamba\envs\dbc_demonstrator\Lib\site-packages\click\core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\HansDembinski\AppData\Local\micromamba\envs\dbc_demonstrator\Lib\site-packages\click\core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\HansDembinski\AppData\Local\micromamba\envs\dbc_demonstrator\Lib\site-packages\convert_single.py", line 35, in main
    save_output(rendered, out_folder, config_parser.get_base_filename(fpath))
  File "C:\Users\HansDembinski\AppData\Local\micromamba\envs\dbc_demonstrator\Lib\site-packages\marker\output.py", line 34, in save_output
    f.write(text)
  File "C:\Users\HansDembinski\AppData\Local\micromamba\envs\dbc_demonstrator\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@VikParuchuri
Copy link
Owner

Thanks for the report and the PR - we had a fix on our dev branch that we just merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants