![](/img/trans.png)
[英]“OSError: [Errno 22] Invalid argument” error when trying to bind to a socket
[英]Trying to save an animation gives error: OSError: Error saving animation to file (cause: [Errno 22] Invalid argument)
我正在嘗試保存 animation,但出現錯誤:
OSError:將 animation 保存到文件時出錯(原因:[Errno 22] 無效參數)標准輸出:b''標准錯誤:b''。 將日志記錄級別設置為 DEBUG 可能有助於重新運行。
我已經安裝了 ffmpeg 並且還在我的代碼中添加了它的路徑。 如果我添加print(animation.writers.list())
,它也會在列表中給出“ffmpeg”,所以我確信我的計算機可以找到正確的文件。
在我的代碼頂部,我有:
import matplotlib.pyplot as plt
plt.rcParams['animation.ffmpeg_path'] = 'C:/FFmpeg/bin/ffmpeg.exe'
在保存 animation 時,我有:
SubplotAnimation_1 = SubplotAnimation(F_vector, eta_atm, Pkid, Tb_sky)
Writer = animation.FFMpegWriter(fps=20, metadata=dict(artist='Me'), extra_args=['--verbose-debug'])
file_string = r'C:/Users/Esmee/Documents/Animations/animation_tryout.mp4'
print(file_string)
SubplotAnimation_1.save(file_string, writer=Writer)
我在字符串前面添加了r
,所以file_string中的/a
沒有問題。 文件夾 C:/Users/Esmee/Documents/Animations/ 肯定存在,所以這也不成問題。 我也試過
Writer = animation.writers['ffmpeg']
mywriter = Writer(fps=15, metadata=dict(artist='Me'), bitrate=1800)
但它也不起作用。
我查看了animation 保存錯誤, 如何克服這個關鍵字錯誤和沒有可用的 Moviewriters ,但它們都沒有解決我的問題。
有誰知道是什么問題? 提前致謝!
最后,下面的代碼起作用了:
Writer = animation.FFMpegWriter(fps=20, metadata=dict(artist='Me'))
file_string = r'C:/Users/Esmee/Documents/Animations/animation_tryout.mp4'
SubplotAnimation_1.save(file_string, writer=Writer)
我認為animation.FFMpegWriter
命令中的參數extra_args=['--verbose-debug']
(我從另一個解決方案中得到)導致程序崩潰。 我沒有更改程序頂部的導入語句中的任何內容。
我希望這篇文章可以幫助任何有類似問題的人!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.