Skip to content

UnicodeEncodeError: 'latin-1' codec can't encode  #23

@bitfoo1

Description

@bitfoo1

Hi,

thank you for providing this handy cli tool.
Unfortunately something went wrong while executing the import command.

papermerge-cli import .

Importing ./Behörden/Eheleute/KiTa/2020.11.18-Eingangsbestätigung Anmeldung Krippenplatz.pdf
Traceback (most recent call last):
  File "/Users/username/.local/share/virtualenvs/username/bin/papermerge-cli", line 8, in <module>
    sys.exit(cli())
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/main.py", line 107, in _import
    perform_import(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 39, in inner
    return func(**kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 54, in inner
    return func(**kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 62, in inner
    return func(*args, **kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/rest.py", line 349, in perform_import
    perform_import(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 39, in inner
    return func(**kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 54, in inner
    return func(**kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 62, in inner
    return func(*args, **kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/rest.py", line 349, in perform_import
    perform_import(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 39, in inner
    return func(**kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 54, in inner
    return func(**kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 62, in inner
    return func(*args, **kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/rest.py", line 349, in perform_import
    perform_import(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 39, in inner
    return func(**kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 54, in inner
    return func(**kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 62, in inner
    return func(*args, **kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/rest.py", line 326, in perform_import
    upload_document(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/utils.py", line 62, in inner
    return func(*args, **kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/backoff/_sync.py", line 105, in retry
    ret = target(*args, **kwargs)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_cli/rest.py", line 150, in upload_document
    documents_api_instance.upload_file(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_restapi_client/paths/api_documents_document_id_upload_file_name/put.py", line 257, in upload_file
    return self._upload_file_oapg(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_restapi_client/paths/api_documents_document_id_upload_file_name/put.py", line 214, in _upload_file_oapg
    response = self.api_client.call_api(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_restapi_client/api_client.py", line 1127, in call_api
    return self.__call_api(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_restapi_client/api_client.py", line 1068, in __call_api
    response = self.request(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_restapi_client/api_client.py", line 1191, in request
    return self.rest_client.PUT(url,
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_restapi_client/rest.py", line 241, in PUT
    return self.request("PUT", url,
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/papermerge_restapi_client/rest.py", line 171, in request
    r = self.pool_manager.request(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/urllib3/request.py", line 78, in request
    return self.request_encode_body(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/urllib3/request.py", line 170, in request_encode_body
    return self.urlopen(method, url, **extra_kw)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/urllib3/poolmanager.py", line 376, in urlopen
    response = conn.urlopen(method, u.request_uri, **kw)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/urllib3/connectionpool.py", line 398, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/urllib3/connection.py", line 239, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1323, in _send_request
    self.putheader(hdr, value)
  File "/Users/username/.local/share/virtualenvs/username/lib/python3.10/site-packages/urllib3/connection.py", line 224, in putheader
    _HTTPConnection.putheader(self, header, *values)
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1255, in putheader
    values[i] = one_value.encode('latin-1')
UnicodeEncodeError: 'latin-1' codec can't encode character '\u0308' in position 45: ordinal not in range(256)

Thank you again for your great work!

I did try to figure it out. But I was not able to fix it. If you want, I would be happy to help in any way.
Daniel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions