2

I have been trying to install AV (https://github.com/PyAV-Org/PyAV#installation) using both:

pip install av

and

pip install av --no-binary av

with no luck. Previously I installed all the system packages as recommended here (https://pyav.org/docs/6.1.2/installation.html):

# General dependencies
sudo apt-get install -y python-dev pkg-config

# Library components
sudo apt-get install -y \
    libavformat-dev libavcodec-dev libavdevice-dev \
    libavutil-dev libswscale-dev libswresample-dev libavfilter-dev

The error I get:

...


 4-3.6/av/video
  copying av/video/format.pxd -> build/lib.linux-x86_64-3.6/av/video
  copying av/data/__init__.pxd -> build/lib.linux-x86_64-3.6/av/data
  copying av/data/stream.pxd -> build/lib.linux-x86_64-3.6/av/data
  copying av/sidedata/sidedata.pxd -> build/lib.linux-x86_64-3.6/av/sidedata
  copying av/sidedata/__init__.pxd -> build/lib.linux-x86_64-3.6/av/sidedata
  copying av/sidedata/motionvectors.pxd -> build/lib.linux-x86_64-3.6/av/sidedata
  copying av/audio/codeccontext.pxd -> build/lib.linux-x86_64-3.6/av/audio
  copying av/audio/plane.pxd -> build/lib.linux-x86_64-3.6/av/audio
  copying av/audio/__init__.pxd -> build/lib.linux-x86_64-3.6/av/audio
  copying av/audio/frame.pxd -> build/lib.linux-x86_64-3.6/av/audio
  copying av/audio/fifo.pxd -> build/lib.linux-x86_64-3.6/av/audio
  copying av/audio/resampler.pxd -> build/lib.linux-x86_64-3.6/av/audio
  copying av/audio/stream.pxd -> build/lib.linux-x86_64-3.6/av/audio
  copying av/audio/layout.pxd -> build/lib.linux-x86_64-3.6/av/audio
  copying av/audio/format.pxd -> build/lib.linux-x86_64-3.6/av/audio
  copying av/subtitles/codeccontext.pxd -> build/lib.linux-x86_64-3.6/av/subtitles
  copying av/subtitles/subtitle.pxd -> build/lib.linux-x86_64-3.6/av/subtitles
  copying av/subtitles/__init__.pxd -> build/lib.linux-x86_64-3.6/av/subtitles
  copying av/subtitles/stream.pxd -> build/lib.linux-x86_64-3.6/av/subtitles
  running build_ext
  building 'av.error' extension
  creating build/temp.linux-x86_64-3.6
  creating build/temp.linux-x86_64-3.6/src
  creating build/temp.linux-x86_64-3.6/src/av
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/x86_64-linux-gnu -I/datadrive/mikel/venvs/scs/include -I/usr/include/python3.6m -c src/av/error.c -o build/temp.linux-x86_64-3.6/src/av/error.o
  src/av/error.c:54:10: fatal error: Python.h: No such file or directory
   #include "Python.h"
            ^~~~~~~~~~
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for av
Failed to build av
ERROR: Could not build wheels for av, which is required to install pyproject.toml-based projects

I suspect I am missing some system packages but I get no hint of which ones.

-------------------------- EDIT1 --------------------------

After:

sudo apt-get install -y python3-dev

as suggested by @phd. I get the following error

  building 'av.codec.codec' extension
  creating build/temp.linux-x86_64-3.6/src/av/codec
  x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/x86_64-linux-gnu -I/datadrive/mikel/venvs/scs/include -I/usr/include/python3.6m -c src/av/codec/codec.c -o build/temp.linux-x86_64-3.6/src/av/codec/codec.o
  src/av/codec/codec.c: In function ‘__pyx_f_2av_5codec_5codec_get_codec_names’:
  src/av/codec/codec.c:4114:19: warning: implicit declaration of function ‘av_codec_iterate’; did you mean ‘av_codec_next’? [-Wimplicit-function-declaration]
       __pyx_v_ptr = av_codec_iterate((&__pyx_v_opaque));
                     ^~~~~~~~~~~~~~~~
                     av_codec_next
  src/av/codec/codec.c:4114:17: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
       __pyx_v_ptr = av_codec_iterate((&__pyx_v_opaque));
                   ^
  src/av/codec/codec.c: In function ‘__pyx_pymod_exec_codec’:
  src/av/codec/codec.c:6226:36: error: ‘AV_CODEC_CAP_HARDWARE’ undeclared (first use in this function); did you mean ‘AV_CODEC_CAP_DR1’?
     __pyx_t_7 = __Pyx_PyInt_From_int(AV_CODEC_CAP_HARDWARE); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 121, __pyx_L1_error)
                                      ^~~~~~~~~~~~~~~~~~~~~
                                      AV_CODEC_CAP_DR1
  src/av/codec/codec.c:6226:36: note: each undeclared identifier is reported only once for each function it appears in
  src/av/codec/codec.c:6247:36: error: ‘AV_CODEC_CAP_HYBRID’ undeclared (first use in this function); did you mean ‘AV_CODEC_CAP_DR1’?
     __pyx_t_7 = __Pyx_PyInt_From_int(AV_CODEC_CAP_HYBRID); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 125, __pyx_L1_error)
                                      ^~~~~~~~~~~~~~~~~~~
                                      AV_CODEC_CAP_DR1
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for av
Failed to build av
ERROR: Could not build wheels for av, which is required to install pyproject.toml-based projects
Mike B
  • 2,136
  • 2
  • 12
  • 31

1 Answers1

0

I ran into the same problem and nothing changed when installing python3-dev, but the problem was solved by installing some other dependencies:

sudo apt-get install -y libavformat-dev libavcodec-dev libavdevice-dev libavutil-dev libswscale-dev libavresample-dev libavfilter-dev libopenmpi-dev

I'm installing av into a Docker container with python=3.8.5 btw.