Trying to save an animation as a gif, but getting error and permission denied

Hi guys, so I’m trying to compile a whole bunch of plots as one moving gif or video using the Plots.jl library alongside ImageMagick. However, whenever I run it, @animate seems to work fine but fails when it tries to input into gif() to save the video file. @gif works fine though. Not I’m working within the Atom text editor. I’ve included the code here, there’s some code before but it’s mostly for calculation and analysing the data:

TS = TDE(usol, 5)

slices = slide(TS, windowsize = 100)
diagrams = []
i=1
for slice in slices
    push!(diagrams,ripserer(pointify(slice)))
    print(i)
    print('\n')
    i = i+1
end

maxlim = 40
x = 0:0.1:maxlim
y = x

#Create Animation
anim = @animate for i in 1:1:length(diagrams)
    plot(diagrams[i], legend = false)
    # pd = diagrams[i]
    # birth0 = birth.(pd[1])
    # death0 = death.(pd[1])
    # birth1 = birth.(pd[2])
    # death1 = death.(pd[2])
    # plot(x,x, linecolor = "black", xlims = (0,maxlim), ylims = (0, maxlim), size = (600,550))
    # scatter!(birth0,death0,
    #             markerstrokealpha = 0, markeralpha = 0.6, markercolor = "deepskyblue")
    # scatter!(birth1,death1,
    #             markerstrokealpha = 0, markeralpha = 0.6, markercolor = "darkorange")
end
gif(anim, "animation.gif", fps = 15)

The error I get is:

**failed process: Process(`'C:\Users\eugen\.julia\artifacts\7350a6401f1c0d38cc3518193083bc4f83adfe99\bin\ffmpeg.exe' -v 16 -framerate 15 -i 'C:\Users\eugen\AppData\Local\Temp\jl_wCSgGt/%06d.png' -i 'C:\Users\eugen\AppData\Local\Temp\jl_wCSgGt/palette.bmp' -lavfi paletteuse=dither=sierra2_4a -loop 0 -y 'C:\Users\eugen\Documents\University Study Documents\PhD Coding\animation.gif'`, ProcessExited(1)) [1]**

in eval at [base\boot.jl:360](#)

in top-level scope at [VineyardAnim.jl:68](#)

in at [Plots\lzHOt\src\animation.jl:64](#)

in #gif#230 at [Plots\lzHOt\src\animation.jl:64](#)

in buildanimation##kw at [Plots\lzHOt\src\animation.jl:78](#)

in buildanimation##kw at [Plots\lzHOt\src\animation.jl:78](#)

in var"#buildanimation#234" at [Plots\lzHOt\src\animation.jl:98](#)

in ffmpeg_exe at [FFMPEG\aazvf\src\FFMPEG.jl:125](#)

in exe##kw at [FFMPEG\aazvf\src\FFMPEG.jl:108](#)

in #exe#2 at [FFMPEG\aazvf\src\FFMPEG.jl:113](#)

in ffmpeg at [JLLWrappers\bkwIo\src\products\executable_generators.jl:7](#)

in #ffmpeg#7 at [JLLWrappers\bkwIo\src\products\executable_generators.jl:7](#)

in invokelatest at [base\essentials.jl:706](#)

in #invokelatest#2 at [base\essentials.jl:708](#)

in withenv_executable_wrapper at [JLLWrappers\bkwIo\src\runtime.jl:48](#)

in withenv at [base\env.jl:161](#)

in at [JLLWrappers\bkwIo\src\runtime.jl:49](#)

in at [FFMPEG\aazvf\src\FFMPEG.jl:114](#)

in run at [base\process.jl:438](#)

in var"#run#648" at [base\process.jl:440](#)

in pipeline_error at [base\process.jl:525](#)

Any help would be greatly appreciated!