whitphx / streamlit-webrtc

Real-time video and audio processing on Streamlit
https://discuss.streamlit.io/t/new-component-streamlit-webrtc-a-new-way-to-deal-with-real-time-media-streams/8669
MIT License
1.41k stars 189 forks source link

ImportError: DLL load failed while importing _core: The specified module could not be found. #623

Open michen00 opened 2 years ago

michen00 commented 2 years ago

I am trying to build my Streamlit app with Travis CI, but I continue to get the ImportError below:

___________________ ERROR collecting msvc/tests/test_app.py ___________________
ImportError while importing test module 'C:\Users\travis\build\michen00\MSVC\msvc\tests\test_app.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
..\..\..\miniconda\envs\msvc_env\lib\importlib\__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
msvc\tests\test_app.py:5: in <module>
    from msvc.src.app import init_session, reset_session  # , submit_button
msvc\src\app.py:10: in <module>
    from streamlit_webrtc import webrtc_streamer, WebRtcMode
..\..\..\miniconda\envs\msvc_env\lib\site-packages\streamlit_webrtc\__init__.py:10: in <module>
    from .component import (
..\..\..\miniconda\envs\msvc_env\lib\site-packages\streamlit_webrtc\component.py:7: in <module>
    from aiortc.mediastreams import MediaStreamTrack
..\..\..\miniconda\envs\msvc_env\lib\site-packages\aiortc\__init__.py:4: in <module>
    import av.logging
..\..\..\miniconda\envs\msvc_env\lib\site-packages\av\__init__.py:9: in <module>
    from av._core import time_base, pyav_version as __version__, library_versions
E   ImportError: DLL load failed while importing _core: The specified module could not be found.

Here are some lines from the environment.yml file that may be relevant:

name: msvc_env
channels:
  - conda-forge
  - pytorch-nightly
  - defaults
dependencies:
  - pip=21.3.1
  - python=3.8.12
  - streamlit=1.4.0=pyhd8ed1ab_1
  - pip:
    - aiortc>=1.2.1
    - av>=8.1.0
    - streamlit-webrtc>=0.34.2

How should I resolve this? Please advise.

whitphx commented 2 years ago

I have not seen this error and also neither familiar with Windows nor TravisCI. Why don't you google the error message, probably with PyAV? I could find the following info for example.

If you installed FFmpeg in some unusual location you'll need to help PyAV find it at runtime. Can you try adding the directory where the .dll lives to your PATH and try again to import av? https://github.com/PyAV-Org/PyAV/issues/490#issuecomment-475980784

I suspect that the module has successfully installed, but is dynamically linked against FFMPEG. https://stackoverflow.com/a/49158534/13103190

michen00 commented 2 years ago

Thanks for getting back to me and helping me to find those posts. I didn't end up solving the problem, but I worked around it by redeveloping my app in a Linux (WSL) environment.

lbourdois commented 2 years ago

I had the same error, I could fix it with pip install av==9.1.0