fujiisoup / sif_parser

A small package to read Andor Technology Multi-Channel files.
BSD 3-Clause "New" or "Revised" License
15 stars 5 forks source link

matplotlib conflict when importing sif_parser is breaking pyplot.plot #20

Closed davesmivers closed 10 months ago

davesmivers commented 1 year ago

Unbuntu 22.04 Python 3.10.6 Minimal virtual environment

I'm getting this error...

Exception has occurred: UnicodeDecodeError 'utf-8' codec can't decode byte 0x89 in position 0: invalid start byte

This doesn't work....

import sif_parser as sif import matplotlib.pyplot as plt plt.plot([1,2,3,4],[1,2,1,2]) plt.show()

This does work...

import sif_parser as sif

import matplotlib.pyplot as plt plt.plot([1,2,3,4],[1,2,1,2]) plt.show()

Digging down a little if I comment out line 23 in the 'plugin' module of sif_parser:

Image.register_open("SIF", SifImageFile)

then this works again

fujiisoup commented 1 year ago

It is wired... I can't reproduce this in my environment. Colabo also works fine https://colab.research.google.com/drive/1BoezvuKMFCJJDg-3smFQjDgkmpEp2hff?usp=share_link

Which environment do you use? Pillow is imported by chance? We have a problem with Pillow. see #14.

mruijzendaal commented 1 year ago

FIY: The error stops appearing if you do not import sif_parser and matplotlib.pyplot in the same module. I made a wrapper module for sif_parser that could be imported in the same module as matplotlib.pyplot. Perhaps you can implement such a workaround in this repo to solve the issue.

mruijzendaal commented 10 months ago

@fujiisoup Could you implement a fix using this method?

fujiisoup commented 10 months ago

I will, but probably this weekend. Sorry for my late response.

mruijzendaal commented 10 months ago

Thanks a lot!