Skip to content

Support for pathlib.Path #1544

Description

@raffaelemancuso

docx.document.Document.add_picture should support pathlib.Path objects.

Currently it returns an error if you try to pass the file name of the image as a pathlib.Path.

Activity

  1. scanny commented on Mar 10, 2026

    @scanny
    Contributor

    Yeah, it was written in the days well before pathlib appeared in Python 3.4.

    If you just do str(path) in your call that will work for both str and pathlib.Path paths.

    But I'll have a look at adding this next time I'm in there :)

  2. added
    pathlib.PathSupport for `pathlib.Path` objects where `str` paths are supported.
    on May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pathlib.PathSupport for `pathlib.Path` objects where `str` paths are supported.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions