Skip to content

Error with pip install av "pkg-config returned flags we don't understand: -pthread -pthread" #510

Closed

Description

@gdavidmac

Trying to install PyAV in a virtualenv with FFMPEG built from source.

PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" pip install av fails with:

  running config
  pkg-config returned flags we don't understand: -pthread -pthread
  ----------------------------------------
  ERROR: Failed building wheel for av
  Running setup.py clean for av

FFMPEG 4.1.3 was built from source according to the usual FFMPEG build instructions. Specific configure and build command was:

cd ~/ffmpeg_source && \
wget -O ffmpeg-4.1.3.tar.bz2 https://ffmpeg.org/releases/ffmpeg-4.1.3.tar.bz2 && \
tar xjvf ffmpeg-4.1.3.tar.bz2 && \
cd ffmpeg-4.1.3 && \
PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \
  --prefix="$HOME/ffmpeg_build" \
  --pkg-config-flags="--static" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" \
  --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --extra-libs="-lpthread -lm" \
  --bindir="$HOME/bin" \
  --enable-gpl \
  --enable-libass \
  --enable-libfdk-aac \
  --enable-libfreetype \
  --enable-libopus \
  --enable-libvorbis \
  --enable-libvpx \
  --enable-libx264 \
  --enable-libx265 \
  --enable-nonfree && \
PATH="$HOME/bin:$PATH" make -j$((`nproc` - 1)) && \
make install && \
hash -r

Activity

  1. changed the title [-]Error with `pip install av` "pkg-config returned flags we don't understand: -pthread -pthread[/-] [+]Error with `pip install av` "pkg-config returned flags we don't understand: -pthread -pthread"[/+] on Apr 26, 2019
  2. jlaine commented on May 2, 2019

    @jlaine
    Member

    Static builds are currently not supported by PyAV's build system.

  3. jlaine commented on May 5, 2019

    @jlaine
    Member

    Modifying PyAV's setup.py to support -pthread is fairly trivial.

    However, after many attempts I have been unable to successfully link against statically compiled ffmpeg libraries. AFAICT ffmpeg has multiple symbols which would need a visibility attribute for a static ffmpeg build to be usable in a shared library such as a Python module.

    That being the case I'm not sure it's worth modifying setup.py..

  4. mikeboers commented on May 7, 2019

    @mikeboers
    Member

    I'll make my periodic ask: anyone know how to detect that it will link against a static library and stop it? So many GitHub issues would be resolved if the build system would just say "We can't link to static FFmpeg."

  5. gregory-whaley commented on May 18, 2019

    @gregory-whaley

    I have a similar error also when trying to install onto Raspbian Jesse. I too had compiled ffmpeg from source. Any suggestions?

    I was successful in compiling PyAV from source, but it is not recognized by python as a module. That is, "import av" fails with "No module named 'av._core'".

  6. jlaine commented on Jun 3, 2019

    @jlaine
    Member

    The suggestion is: don't create a static ffmpeg build. Also if you use Raspbian Stretch, you should already have a pre-compiled PyAV, courtesy of piwheels: https://www.piwheels.org/project/av/

  7. hsharrison commented on Jul 12, 2019

    @hsharrison

    I'm trying to compile PyAv in order to use the hwaccel branch, and I'm having trouble. I started with a clean VM and didn't compile anything myself besides running scripts/build-deps. It compiled succesfuly but now I'm getting No module named 'av._core'. Any ideas what went wrong?

    Edit: nevermind, I didn't have pkg-config. Installed then, then ran make again, and I'm up and running.

  8. ramoncaldeira commented on Jul 18, 2019

    @ramoncaldeira
    Contributor

    I've experienced this error trying to use the av package with an ffmpeg build configured to use h264_cuvid as a hardware decoder. It is not a static build.

      Running setup.py install for av: started
        Running setup.py install for av: finished with status 'error'
        ERROR: Complete output from command /apps/conda/ramon.caldeira/.envs/av/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-ajt1foa1/av/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-_ksbgq8i/install-record.txt --single-version-externally-managed --compile:
        ERROR: running install
        running build
        running build_py
        creating build
        creating build/lib.linux-x86_64-3.7
        creating build/lib.linux-x86_64-3.7/av
        copying av/__main__.py -> build/lib.linux-x86_64-3.7/av
        copying av/__init__.py -> build/lib.linux-x86_64-3.7/av
        copying av/datasets.py -> build/lib.linux-x86_64-3.7/av
        copying av/deprecation.py -> build/lib.linux-x86_64-3.7/av
        creating build/lib.linux-x86_64-3.7/av/codec
        copying av/codec/__init__.py -> build/lib.linux-x86_64-3.7/av/codec
        creating build/lib.linux-x86_64-3.7/av/video
        copying av/video/__init__.py -> build/lib.linux-x86_64-3.7/av/video
        creating build/lib.linux-x86_64-3.7/av/subtitles
        copying av/subtitles/__init__.py -> build/lib.linux-x86_64-3.7/av/subtitles
        creating build/lib.linux-x86_64-3.7/av/container
        copying av/container/__init__.py -> build/lib.linux-x86_64-3.7/av/container
        creating build/lib.linux-x86_64-3.7/av/filter
        copying av/filter/__init__.py -> build/lib.linux-x86_64-3.7/av/filter
        creating build/lib.linux-x86_64-3.7/av/data
        copying av/data/__init__.py -> build/lib.linux-x86_64-3.7/av/data
        creating build/lib.linux-x86_64-3.7/av/audio
        copying av/audio/__init__.py -> build/lib.linux-x86_64-3.7/av/audio
        running build_ext
        running config
        pkg-config returned flags we don't understand: -pthread -pthread
    
  9. Fruchtzwerg94 commented on Jul 28, 2019

    @Fruchtzwerg94

    I hat the same problem. The following solution worked for me:

    1. Building ffmpeg with the flag --enable-shared
    2. Check ffmpeg is running, maybe the lib path is missing (add /usr/local/lib to LD_LIBRARY_PATH)
    3. Clone PyAV
    4. Comment out line 95 in setup.py
    5. source scripts/activate.sh
    6. make
    7. Add the directory to PYTHONPATH if you are not installing the package
  10. ReuvenSwirsky commented on Apr 16, 2020

    @ReuvenSwirsky

    @Fruchtzwerg94 -- did you have to add -fPIC to cflags when building the ffmpeg that PyAV is linking to? I'm getting a linker error and I don't want to be running down a rathole. (Trying it though!)

  11. Fruchtzwerg94 commented on Apr 17, 2020

    @Fruchtzwerg94

    @Fruchtzwerg94 -- did you have to add -fPIC to cflags when building the ffmpeg that PyAV is linking to? I'm getting a linker error and I don't want to be running down a rathole. (Trying it though!)

    No, I didn't specify any other linker flags.

  12. ReuvenSwirsky commented on Apr 17, 2020

    @ReuvenSwirsky

    I'm getting these errors. I tried -fPIC, too, and still got it. I need to check to see if they really were compiled right.

    /bin/ld: /usr/local/lib/libavdevice.a(fbdev_common.o): relocation R_X86_64_32 against `.rodata' can not be used when ma
    king a shared object; recompile with -fPIC
    /bin/ld: /usr/local/lib/libavdevice.a(oss.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when maki
    ng a shared object; recompile with -fPIC
    /bin/ld: /usr/local/lib/libavdevice.a(v4l2-common.o): relocation R_X86_64_32 against symbol `ff_fmt_conversion_table' c
    an not be used when making a shared object; recompile with -fPIC
    
  13. jkurdzieko commented on Apr 21, 2020

    @jkurdzieko

    I have same errors, too. Did you find solution.

  14. ReuvenSwirsky commented on Apr 21, 2020

    @ReuvenSwirsky

    I have same errors, too. Did you find solution.

    Yes, I had to take a private copy and comment out the line in the setup.py that calls exit(0) if it sees this flag. I also had to add the flag --enable-shared (and -fPIC) to a private build of ffmpeg 4.1.x

  15. jlaine commented on Apr 26, 2020

    @jlaine
    Member

    As of PyAV 8.0.0, binary wheels are provided which will greatly simplify installation and should solve your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions