Ffmpeg已经安装,但我得到了一个例外:你的机器上没有安装Ffmpeg

  • 本文关键字:Ffmpeg 安装 一个 机器 python ffmpeg
  • 更新时间 :
  • 英文 :


我已经搜索了几个小时的解决方案,但还没有找到。也许这里有人知道出了什么问题。

我正在尝试用Python制作一个条形图比赛。虽然我已经下载并安装了Ffmpeg,我不断收到多个错误:

MovieWriter ffmpeg unavailable; using Pillow instead.
Traceback (most recent call last):
File "/Users/___/PycharmProjects/data_visualization/venv/lib/python3.6/site-        packages/matplotlib/animation.py", line 251, in saving
yield self
File "/Users/___/PycharmProjects/data_visualization/venv/lib/python3.6/site-        packages/matplotlib/animation.py", line 1161, in save
writer.grab_frame(**savefig_kwargs)
File "/Users/____/PycharmProjects/data_visualization/venv/lib/python3.6/site-        packages/matplotlib/animation.py", line 549, in grab_frame
renderer = self.fig.canvas.get_renderer()
AttributeError: 'FigureCanvasBase' object has no attribute 'get_renderer'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/___/PycharmProjects/data_visualization/venv/lib/python3.6/site-        packages/bar_chart_race/_make_chart.py", line 435, in make_animation
ret_val = anim.save(self.filename, fps=self.fps, writer=self.writer)
File "/Users/___/PycharmProjects/data_visualization/venv/lib/python3.6/site-        packages/matplotlib/animation.py", line 1161, in save
writer.grab_frame(**savefig_kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line         100, in __exit__
self.gen.throw(type, value, traceback)
File "/Users/___/PycharmProjects/data_visualization/venv/lib/python3.6/site-                        packages/matplotlib/animation.py", line 253, in saving
self.finish()
File "/Users/____/PycharmProjects/data_visualization/venv/lib/python3.6/site-        packages/matplotlib/animation.py", line 554, in finish
self._frames[0].save(
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Exception: You do not have ffmpeg installed on your machine. Download
ffmpeg from here: https://www.ffmpeg.org/download.html.
Matplotlib's original error message below:
list index out of range

我试过用conda、pip和自制软件安装ffmpeg。当我检查版本时,我得到以下信息:

ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
built with clang version 9.0.1
configuration: --prefix=/Users/___/opt/miniconda3 --cc=x86_64-apple-darwin13.4.0-clang --disable-doc --disable-openssl --enable-avresample --enable-gnutls --enable-gpl --enable-hardcoded-tables --enable-libfreetype --enable-libopenh264 --enable-libx264 --enable-pic --enable-pthreads --enable-shared --enable-static --enable-version3 --enable-zlib --enable-libmp3lame
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libavresample   4.  0.  0 /  4.  0.  0
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100

这是代码:

import numpy as np
import pandas as pd
import bar_chart_race as bcr
import os

df = pd.read_csv('/Users/____/Documents/data/dummy_data.csv', delimiter=';', encoding="utf-8-sig")
bcr.bar_chart_race(
df=df,
filename='test_win2.mov',
orientation='h',
sort='desc',
n_bars=8,
fixed_order=False,
fixed_max=False,
steps_per_period=50,
interpolate_period=False,
label_bars=True,
bar_size=.95,
period_label={'x': .99, 'y': .25, 'ha': 'right', 'va': 'center'},
period_summary_func=lambda v, r: {'x': .99, 'y': .18,
's': f'Totaal: {v.nlargest(8).sum():,.0f}',
'ha': 'right', 'size': 8, 'family': 'Courier New'},
perpendicular_bar_func='median',
figsize=(3.5, 3),
period_length=100,
dpi=300,
cmap='dark12',
title='Title?',
title_size='',
bar_label_size=4,
tick_label_size=4,
shared_fontdict={'family': 'Helvetica', 'color': '.1'},
scale='linear',
writer=None,
fig=None,
bar_kwargs={'alpha': .3},
filter_column_colors=False)

读取CSVXlSX文件时,必须指定索引列在您的情况下是

df = pd.read_csv('/Users/____/Documents/data/dummy_data.csv', *index_col='index'*, delimiter=';', encoding="utf-8-sig")

并将索引替换为要用作索引的列

请参阅此了解更多信息。

最新更新