Skip to content

Convert image error #1036

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

Open
t-kalinowski opened this issue Feb 19, 2025 · 0 comments
Open

Convert image error #1036

t-kalinowski opened this issue Feb 19, 2025 · 0 comments

Comments

@t-kalinowski
Copy link
Contributor

Running the example in the README raises an exception.

Passing llm_client either to MarkItDown.__init__ or MarkItDown.convert both raise (different) exceptions.

Python 3.11.11 (main, Dec  6 2024, 21:09:50) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> from markitdown import MarkItDown
>>> from openai import OpenAI
>>> 
>>> jpg = "/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/doc/html/logo.jpg"
>>> client = OpenAI()
>>> md = MarkItDown(llm_client=client, llm_model="gpt-4o")
>>> result = md.convert(jpg)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tomasz/Library/Caches/r-reticulate/uv-cache/archive-v0/R0ddJ1irS2gmVKTHSO72g/lib/python3.11/site-packages/markitdown/_markitdown.py", line 193, in convert
    return self.convert_local(source, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/Library/Caches/r-reticulate/uv-cache/archive-v0/R0ddJ1irS2gmVKTHSO72g/lib/python3.11/site-packages/markitdown/_markitdown.py", line 217, in convert_local
    return self._convert(path, extensions, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/Library/Caches/r-reticulate/uv-cache/archive-v0/R0ddJ1irS2gmVKTHSO72g/lib/python3.11/site-packages/markitdown/_markitdown.py", line 368, in _convert
    raise FileConversionException(
markitdown._exceptions.FileConversionException: Could not convert '/Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/doc/html/logo.jpg' to Markdown. File type was recognized as ['.jpg', '.jpg', '.jfif', '.jpeg', '.jpe']. While converting the file, the following error was encountered:

Traceback (most recent call last):
  File "/Users/tomasz/Library/Caches/r-reticulate/uv-cache/archive-v0/R0ddJ1irS2gmVKTHSO72g/lib/python3.11/site-packages/markitdown/_markitdown.py", line 352, in _convert
    res = converter.convert(local_path, **_kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/Library/Caches/r-reticulate/uv-cache/archive-v0/R0ddJ1irS2gmVKTHSO72g/lib/python3.11/site-packages/markitdown/converters/_image_converter.py", line 49, in convert
    + self._get_llm_description(
      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/Library/Caches/r-reticulate/uv-cache/archive-v0/R0ddJ1irS2gmVKTHSO72g/lib/python3.11/site-packages/markitdown/converters/_image_converter.py", line 70, in _get_llm_description
    content_type, encoding = mimetypes.guess_type("_dummy" + extension)
                             ^^^^^^^^^
NameError: name 'mimetypes' is not defined
>>> md = MarkItDown()
>>> result = md.convert(jpg, llm_client=client, llm_model="gpt-4o")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tomasz/Library/Caches/r-reticulate/uv-cache/archive-v0/R0ddJ1irS2gmVKTHSO72g/lib/python3.11/site-packages/markitdown/_markitdown.py", line 193, in convert
    return self.convert_local(source, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/Library/Caches/r-reticulate/uv-cache/archive-v0/R0ddJ1irS2gmVKTHSO72g/lib/python3.11/site-packages/markitdown/_markitdown.py", line 217, in convert_local
    return self._convert(path, extensions, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/Library/Caches/r-reticulate/uv-cache/archive-v0/R0ddJ1irS2gmVKTHSO72g/lib/python3.11/site-packages/markitdown/_markitdown.py", line 325, in _convert
    _kwargs = copy.deepcopy(kwargs)
              ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 172, in deepcopy
    y = _reconstruct(x, memo, *rv)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 271, in _reconstruct
    state = deepcopy(state, memo)
            ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 146, in deepcopy
    y = copier(x, memo)
        ^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 231, in _deepcopy_dict
    y[deepcopy(key, memo)] = deepcopy(value, memo)
                             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/tomasz/.local/share/uv/python/cpython-3.11.11-macos-aarch64-none/lib/python3.11/copy.py", line 161, in deepcopy
    rv = reductor(4)
         ^^^^^^^^^^^
TypeError: cannot pickle '_thread.RLock' object
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

No branches or pull requests

1 participant