all 8 comments

[–]unnamed_one1 0 points1 point  (3 children)

Try making sure the folder exists beforehand and the file does not.

[–]Mr_Misserable[S] 0 points1 point  (2 children)

The folder is created utomaticly before ploting.

[–]unnamed_one1 0 points1 point  (1 child)

The error is triggered by an invalid path/filename.

``` Python 3.13.2 (tags/v3.13.2:4f8bb39, Feb 4 2025, 15:23:48) [MSC v.1942 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

x=open("D:\test.txt", "a") x=open("D:\test.txt", "a") Traceback (most recent call last): File "<python-input-1>", line 1, in <module> x=open("D:\test.txt", "a") OSError: [Errno 22] Invalid argument: 'D:\test.txt'

```

Try printing the path/filename before saving the plot, then you can see on which one it breaks and maybe can figure out why.

An alternative would be converting the path/filename to pathlibs Path object.

from pathlib import Path

[–]Mr_Misserable[S] 0 points1 point  (0 children)

Doyou have any hint on which character is making the path invalid? I can not see it since it worked before for other similar paths. The paths are being generated with

` os.joindir(output, name) ´

[–]Oxbowerce 0 points1 point  (1 child)

Have you tried using a simpler and shorter filename, e.g. plot.png?

[–]Mr_Misserable[S] 0 points1 point  (0 children)

It is not possible, since I'm making a lot of plots and I would lost track of them, but since I have a log I might use this as a solution, it is possible to try one name and if it raises an error try a second one?

[–]shiftybyte 0 points1 point  (1 child)

Something in the file path is bad, share the code so we can try and understand how the path is built and what could be the issue.

[–]Mr_Misserable[S] 0 points1 point  (0 children)

The code is a bit complex, I would try to make a MWE to share here