Skip to content

gui backends do not work inside of flask request handlers #12612

@ghost

Description

Bug report

Bug summary

Hi i am trying to plot an image using the plt.imshow() function.

Code for reproduction

        base64_data = req.get("base64")
        decoded = Image.open(BytesIO(base64.b64decode(base64_data)))
        arr = cv2.cvtColor(np.array(decoded), cv2.COLOR_BGR2RGB)
        gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

        ret, threshold = cv2.threshold(gray, 100, 255, cv2.THRESH_BINARY)

        plt.axis("off")
        plt.imshow(image)
        plt.show()

Actual outcome

2018-10-24 10:11:40.636 python[69065:3191133] It does not make sense to draw an image when [NSGraphicsContext currentContext] is nil. This is a programming error. Break on void _NSWarnForDrawingImageWithNoCurrentContext(void) to debug. This will be logged only once. This may break in the future.

Expected outcome

A plot with the image.

Matplotlib version

  • Operating system: macOS High Sierra version 10.13.3
  • Matplotlib version: ==3.0.0
  • Matplotlib backend TkAgg
  • Python version: 3.7
  • Other libraries: cv2, Flask

pipenv install matplotlib

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