Home > database >  _tkinter.TclError: couldnt't open ....\matplotlib_128.ppm : no such file or directory
_tkinter.TclError: couldnt't open ....\matplotlib_128.ppm : no such file or directory

Time:04-27

I am new to scripting with Python and this is my first post on stackoverflow (so I hope I phrase this question correctly).

I encountered a problem by using matplotlib. For the sake of this post I simplyfied my code to the lines which cause the problem.

import matplotlib.pyplot as plt

y_vals = [1, 2, 3, 4, 5]
x_vals = [1, 2, 3, 4, 5]

plt.plot(y_vals, x_vals)
plt.show()

When I run the code I recieve the following error message:

  File "c:\Users\bachm\Desktop\tmp\GUI_interface.py", line 52, in <module>
    ani = FuncAnimation(plt.gcf(), animate, interval = 1, repeat = anim_running)
  File "C:\Users\bachm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\matplotlib\pyplot.py", line 846, in gcf
    return figure()
  File "C:\Users\bachm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\matplotlib\pyplot.py", line 787, in figure
    manager = new_figure_manager(
  File "C:\Users\bachm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\matplotlib\pyplot.py", line 306, in new_figure_manager
    return _backend_mod.new_figure_manager(*args, **kwargs)
  File "C:\Users\bachm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\matplotlib\backend_bases.py", line 3494, in new_figure_manager
    return cls.new_figure_manager_given_figure(num, fig)
  File "C:\Users\bachm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\matplotlib\backends\_backend_tk.py", line 934, in new_figure_manager_given_figure
    icon_img = tk.PhotoImage(file=icon_fname, master=window)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 4093, in __init__
    Image.__init__(self, 'photo', name, cnf, master, **kw)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1264.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py", line 4038, in __init__
    self.tk.call(('image', 'create', imgtype, name,)   options)
_tkinter.TclError: couldn't open "C:\Users\bachm\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\matplotlib\mpl-data\images\matplotlib_128.ppm": no such file or directory

When I check the directory the file exists and also when running the code (in VS Code) in the interactive mode the plot is generated.

This problem is giving me a huge headache and I cannot figure out why it is not running.

Thanks in advance and in chase something is unclear or phrased wrong please let me know! Cheers

CodePudding user response:

Try install pip and in cmd write "pip install matplotlib".

CodePudding user response:

Update: I (think) figured it out and the code is running now. The length of the directory exceeded the number of elements supported (255) by windows.

  • Related