Search code examples
python-3.xopenai-whisper

Simple import is throwing an error; any ideas on why I'm not able to import whisper using python?


I was able to successfully run my code earlier today, but as of this evening I am getting a syntax error when trying to import Whisper. Any ideas?

line 9, in <module>
    import whisper
  File "/miniconda/lib/python3.7/site-packages/whisper/__init__.py", line 11, in <module>
    from .audio import load_audio, log_mel_spectrogram, pad_or_trim
  File "/miniconda/lib/python3.7/site-packages/whisper/audio.py", line 10, in <module>
    from .utils import exact_div
  File "/miniconda/lib/python3.7/site-packages/whisper/utils.py", line 108
    if word_timings := segment.get("words", None):
                     ^
SyntaxError: invalid syntax

Solution

  • The walrus operator raising the error is only available since Python 3.8. It seems you are working with Python 3.7.