SjoerdTilmans / sjvisualizer

Library to make animated data visualizations from time series data
https://www.sjdataviz.com/software
MIT License
199 stars 30 forks source link

invalid command name "PyImagingPhoto" on macos M1 #30

Open markqiu opened 2 months ago

markqiu commented 2 months ago
Traceback (most recent call last):
  File "/Users/qiucheng/work/principle/.venv/lib/python3.11/site-packages/PIL/ImageTk.py", line 65, in _pyimagingtkcall
    tk.call(command, photo, id)
_tkinter.TclError: invalid command name "PyImagingPhoto"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/qiucheng/work/principle/packages/jinniuai-visualization/src/jinniuai_visualization/animations/动态基础比较.py", line 3, in <module>
    plt.line(excel="../data/基础比较.xlsx",
  File "/Users/qiucheng/work/principle/.venv/lib/python3.11/site-packages/sjvisualizer/plot.py", line 313, in line
    canvas.play(fps=fps, record=record, file_name=output_video)
  File "/Users/qiucheng/work/principle/.venv/lib/python3.11/site-packages/sjvisualizer/Canvas.py", line 199, in play
    self._add_sj_logo()
  File "/Users/qiucheng/work/principle/.venv/lib/python3.11/site-packages/sjvisualizer/Canvas.py", line 295, in _add_sj_logo
    img = StaticImage.static_image(canvas=self.canvas, width=int(self.width / 45), height=int(self.width / 45),
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/qiucheng/work/principle/.venv/lib/python3.11/site-packages/sjvisualizer/Canvas.py", line 425, in __init__
    self.draw(self.start_time)
  File "/Users/qiucheng/work/principle/.venv/lib/python3.11/site-packages/sjvisualizer/StaticImage.py", line 95, in draw
    img = cv.load_image(self.file, self.width, self.height, self.root, self.file)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/qiucheng/work/principle/.venv/lib/python3.11/site-packages/sjvisualizer/Canvas.py", line 482, in load_image
    load = ImageTk.PhotoImage(load)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/qiucheng/work/principle/.venv/lib/python3.11/site-packages/PIL/ImageTk.py", line 129, in __init__
    self.paste(image)
  File "/Users/qiucheng/work/principle/.venv/lib/python3.11/site-packages/PIL/ImageTk.py", line 183, in paste
    _pyimagingtkcall("PyImagingPhoto", self.__photo, block.id)
  File "/Users/qiucheng/work/principle/.venv/lib/python3.11/site-packages/PIL/ImageTk.py", line 69, in _pyimagingtkcall
    from . import _imagingtk
TypeError: bad argument type for built-in operation

did somebody else ever meet this error before?

markqiu commented 2 months ago

It has been solved by copying all lib file uder python lib directory. image

SjoerdTilmans commented 2 months ago

@markqiu , thank you for posting the solution here :)