[Solved] Win10 Install pyav Error: ERROR: Failed building wheel for avFailed to build av. ERROR: Could not build wheel

Python3. 6: In win10 environment, use the following command to install pyav:

pip install av

Failed to install pyav, here is the error message:

        ERROR: Failed building wheel for av
        Failed to build av
        ERROR: Could not build wheels for av which use PEP 517 and cannot be installed directly:


(C:\Users\Jayce\Anaconda3\envs\tf1.7) E:\Code\Python>pip install av
Looking in indexes: https://pypi.doubanio.com/simple
Collecting av
  Downloading https://pypi.doubanio.com/packages/00/3f/9fe21065912902a7856a69df334a67b73a51da5e08ff033fd79f15d05764/av-9.1.1.tar.gz (2.4 MB)
     |████████████████████████████████| 2.4 MB 3.2 MB/s
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: av
  Building wheel for av (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Jayce\Anaconda3\envs\tf1.7\python.exe' 'C:\Users\Jayce\Anaconda3\envs\tf1.7\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\J
       cwd: C:\Users\Jayce\AppData\Local\Temp\pip-install-hi4s2fdw\av_03c9287622cf4da7918135c5be424e7b
  Complete output (38 lines):
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.6
  creating build\lib.win-amd64-3.6\av
  copying av\about.py -> build\lib.win-amd64-3.6\av
  copying av\datasets.py -> build\lib.win-amd64-3.6\av
  copying av\deprecation.py -> build\lib.win-amd64-3.6\av
  copying av\__init__.py -> build\lib.win-amd64-3.6\av
  copying av\__main__.py -> build\lib.win-amd64-3.6\av
  creating build\lib.win-amd64-3.6\av\audio
  copying av\audio\__init__.py -> build\lib.win-amd64-3.6\av\audio
  creating build\lib.win-amd64-3.6\av\codec
  copying av\codec\__init__.py -> build\lib.win-amd64-3.6\av\codec
  creating build\lib.win-amd64-3.6\av\container
  copying av\container\__init__.py -> build\lib.win-amd64-3.6\av\container
  creating build\lib.win-amd64-3.6\av\data
  copying av\data\__init__.py -> build\lib.win-amd64-3.6\av\data
  creating build\lib.win-amd64-3.6\av\filter
  copying av\filter\__init__.py -> build\lib.win-amd64-3.6\av\filter
  creating build\lib.win-amd64-3.6\av\sidedata
  copying av\sidedata\__init__.py -> build\lib.win-amd64-3.6\av\sidedata
  creating build\lib.win-amd64-3.6\av\subtitles
  copying av\subtitles\__init__.py -> build\lib.win-amd64-3.6\av\subtitles
  creating build\lib.win-amd64-3.6\av\video
  copying av\video\__init__.py -> build\lib.win-amd64-3.6\av\video
  running build_ext
  building 'av.buffer' extension
  creating build\temp.win-amd64-3.6
  creating build\temp.win-amd64-3.6\Release
  creating build\temp.win-amd64-3.6\Release\src
  creating build\temp.win-amd64-3.6\Release\src\av
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c logo /Ox /W3 /GL /DNDEBUG /MD -IC:\Users\Jayce\Anaconda3\envs\tf1.7\include -IC:\Users\Jayce\Anaconda
3\envs\tf1.7\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Wi
ndows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tcsrc\av\buffer.c /Fobuild\temp.win-amd6
  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\link.exe logo /INCREMENTAL:NO /LTCG /DLL /MANIFEST:EMBED,ID=2 /MANIFESTUAC:NO /LIBPATH:C:\Users\Jayce\Anaconda3
\envs\tf1.7\libs /LIBPATH:C:\Users\Jayce\Anaconda3\envs\tf1.7\PCbuild\amd64 "/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\amd64" "/LIBPATH:C:\Program Files (x86)\
Windows Kits\10\lib\10.0.10240.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x64" avformat.lib avcodec.lib avdevice.lib avutil.lib avfilter.lib swscale.li
b swresample.lib /EXPORT:PyInit_buffer build\temp.win-amd64-3.6\Release\src\av\buffer.obj /OUT:build\lib.win-amd64-3.6\av\buffer.cp36-win_amd64.pyd /IMPLIB:build\temp.win-amd64-3.6\Rele
  LINK : fatal error LNK1181: cannot open input file 'avformat.lib'
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\link.exe' failed with exit status 1181
  ERROR: Failed building wheel for av
Failed to build av
ERROR: Could not build wheels for av which use PEP 517 and cannot be installed directly

This is because installing without a version number will install the latest version of pyav, which is not suitable for Python 3 6, so you need to compile it yourself, and you need to install ffmpeg for your own compilation, which leads to compilation errors because there is no ffmpeg.

1. Either install ffmpeg by yourself and compile it;

2. Or go straight to find the whl file of Python 3.6, direct installation;

I directly found the latest support for Python 3 on the mirror website Pyav of 6 is 8.0.3. Download and install:

Or add the version number of Python 3.6 in the PIP command:

pip install av==8.0.3

Read More: