Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] pyaudio error, module 'pkgutil' has no attribute 'ImpImporter' #56

Closed
dazWiLLiE opened this issue Aug 7, 2024 · 10 comments
Closed

Comments

@dazWiLLiE
Copy link

Steps to reproduce

Followed the guide, cloned repo, started the virtualenv, run 'pip install -r requirements.txt'
Get the error message:

Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      Traceback (most recent call last):
        File "/home/magnus/xx/audiotext/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/magnus/xx/audiotext/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/magnus/xx/audiotext/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 112, in get_requires_for_build_wheel
          backend = _build_backend()
                    ^^^^^^^^^^^^^^^^
        File "/home/magnus/xx/audiotext/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
          obj = import_module(mod_path)
                ^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 995, in exec_module
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "/tmp/pip-build-env-3e896ujr/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
          import setuptools.version
        File "/tmp/pip-build-env-3e896ujr/overlay/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
          import pkg_resources
        File "/tmp/pip-build-env-3e896ujr/overlay/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2191, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [end of output]

I'm on Arch, which uses python 3.12.4

I saw the other bug report on this issue that it should be fixed, but it still happens to me.

@HenestrosaDev
Copy link
Owner

HenestrosaDev commented Aug 7, 2024

It seems that the pkgutil.ImpImporter class has been removed in Python 3.12. Can you run the following commands in the virtualenv?

pip install --upgrade setuptools
python -m ensurepip --upgrade

After that, try running pip install -r requirements.txt again. Let me know if this fixes your issue.

@dazWiLLiE
Copy link
Author

❯ pip install --upgrade setuptools
Requirement already satisfied: setuptools in ./venv/lib/python3.12/site-packages (72.1.0)

❯ python -m ensurepip --upgrade
Looking in links: /tmp/tmpvtccgdws
Requirement already satisfied: pip in ./venv/lib/python3.12/site-packages (24.2)

Already tried that, but did it again and got the same message.

@HenestrosaDev
Copy link
Owner

Can you try running python -m pip install -r requirements.txt?

@dazWiLLiE
Copy link
Author

Collecting pyaudio==0.2.13 (from -r requirements.txt (line 6))
  Using cached PyAudio-0.2.13.tar.gz (46 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error
  
  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [33 lines of output]
      Traceback (most recent call last):
        File "/home/magnus/xx/audiotext/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/home/magnus/xx/audiotext/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/magnus/xx/audiotext/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 112, in get_requires_for_build_wheel
          backend = _build_backend()
                    ^^^^^^^^^^^^^^^^
        File "/home/magnus/xx/audiotext/venv/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
          obj = import_module(mod_path)
                ^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.12/importlib/__init__.py", line 90, in import_module
          return _bootstrap._gcd_import(name[level:], package, level)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
        File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
        File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
        File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
        File "<frozen importlib._bootstrap_external>", line 995, in exec_module
        File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
        File "/tmp/pip-build-env-mhncmzmx/overlay/lib/python3.12/site-packages/setuptools/__init__.py", line 16, in <module>
          import setuptools.version
        File "/tmp/pip-build-env-mhncmzmx/overlay/lib/python3.12/site-packages/setuptools/version.py", line 1, in <module>
          import pkg_resources
        File "/tmp/pip-build-env-mhncmzmx/overlay/lib/python3.12/site-packages/pkg_resources/__init__.py", line 2191, in <module>
          register_finder(pkgutil.ImpImporter, find_on_path)
                          ^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'pkgutil' has no attribute 'ImpImporter'. Did you mean: 'zipimporter'?
      [end of output]

Same error

@dazWiLLiE
Copy link
Author

❯ python -m pip install -r requirements.txt
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu121
Collecting customtkinter==5.2.1 (from -r requirements.txt (line 3))
  Using cached customtkinter-5.2.1-py3-none-any.whl.metadata (652 bytes)
Collecting moviepy==1.0.3 (from -r requirements.txt (line 4))
  Using cached moviepy-1.0.3.tar.gz (388 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting openai==1.36.0 (from -r requirements.txt (line 5))
  Using cached openai-1.36.0-py3-none-any.whl.metadata (22 kB)
Collecting pyaudio==0.2.13 (from -r requirements.txt (line 6))
  Using cached PyAudio-0.2.13.tar.gz (46 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error

The top part.

@HenestrosaDev
Copy link
Owner

Did you take into account the second bullet point in the Notes section of the README? If not, please follow the instructions and tell me if this solved your issue.

@dazWiLLiE
Copy link
Author

Yes.

extra/portaudio 1:19.7.0-3 (100.0 KiB 336.9 KiB) (Installed)

Developer files is installed.

❯ sudo pacman -Ql portaudio
portaudio /usr/
portaudio /usr/include/
portaudio /usr/include/pa_jack.h
portaudio /usr/include/pa_linux_alsa.h
portaudio /usr/include/portaudio.h
portaudio /usr/include/portaudiocpp/
portaudio /usr/include/portaudiocpp/AutoSystem.hxx
portaudio /usr/include/portaudiocpp/BlockingStream.hxx
portaudio /usr/include/portaudiocpp/CFunCallbackStream.hxx
portaudio /usr/include/portaudiocpp/CallbackInterface.hxx
portaudio /usr/include/portaudiocpp/CallbackStream.hxx
portaudio /usr/include/portaudiocpp/CppFunCallbackStream.hxx
portaudio /usr/include/portaudiocpp/Device.hxx
portaudio /usr/include/portaudiocpp/DirectionSpecificStreamParameters.hxx
portaudio /usr/include/portaudiocpp/Exception.hxx
portaudio /usr/include/portaudiocpp/HostApi.hxx
portaudio /usr/include/portaudiocpp/InterfaceCallbackStream.hxx
portaudio /usr/include/portaudiocpp/MemFunCallbackStream.hxx
portaudio /usr/include/portaudiocpp/PortAudioCpp.hxx
portaudio /usr/include/portaudiocpp/SampleDataFormat.hxx
portaudio /usr/include/portaudiocpp/Stream.hxx
portaudio /usr/include/portaudiocpp/StreamParameters.hxx
portaudio /usr/include/portaudiocpp/System.hxx
portaudio /usr/include/portaudiocpp/SystemDeviceIterator.hxx
portaudio /usr/include/portaudiocpp/SystemHostApiIterator.hxx
portaudio /usr/lib/
portaudio /usr/lib/libportaudio.so
portaudio /usr/lib/libportaudio.so.2
portaudio /usr/lib/libportaudio.so.2.0.0
portaudio /usr/lib/libportaudiocpp.so
portaudio /usr/lib/libportaudiocpp.so.0
portaudio /usr/lib/libportaudiocpp.so.0.0.12
portaudio /usr/lib/pkgconfig/
portaudio /usr/lib/pkgconfig/portaudio-2.0.pc
portaudio /usr/lib/pkgconfig/portaudiocpp.pc
portaudio /usr/share/
portaudio /usr/share/doc/
portaudio /usr/share/doc/portaudio/
portaudio /usr/share/doc/portaudio/README.configure.txt
portaudio /usr/share/doc/portaudio/README.md
portaudio /usr/share/licenses/
portaudio /usr/share/licenses/portaudio/
portaudio /usr/share/licenses/portaudio/LICENSE.txt

However, bumping pyAudio to 0.2.14 in requirements.txt results in installing without error.

Let's see if its working.

@dazWiLLiE
Copy link
Author

Well, I did get this error:

$ python src/app.py
Traceback (most recent call last):
  File "/home/magnus/xx/audiotext/src/app.py", line 86, in <module>
    app = App()
          ^^^^^
  File "/home/magnus/xx/audiotext/src/app.py", line 26, in __init__
    self.wm_iconbitmap(ph.ROOT_PATH / ph.IMG_RELATIVE_PATH / "icon.ico")
  File "/home/magnus/xx/audiotext/venv/lib/python3.12/site-packages/customtkinter/windows/ctk_tk.py", line 228, in wm_iconbitmap
    super().wm_iconbitmap(bitmap, default)
  File "/usr/lib/python3.12/tkinter/__init__.py", line 2156, in wm_iconbitmap
    return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: bitmap "/home/magnus/xx/audiotext/res/img/icon.ico" not defined

So I edited:
audiotext/venv/lib/python3.12/site-packages/customtkinter/windows/ctk_tk.py

and commented out:

    def wm_iconbitmap(self, bitmap=None, default=None):
        self._iconbitmap_method_called = True
#        super().wm_iconbitmap(bitmap, default)

..and the program started.

I selected an mkv file with english audio (english is selected, WhisperX, srt, gpu found, nothing else changed), and
when clicking on "Generate transcription", I get this:
TypeError("'NoneType' object does not support item assignment")

In the terminal I can see:

$ python src/app.py
Value for [whisperx][can_use_gpu] modified to True
Value for [transcription][audio_source] modified to File
Value for [whisperx][output_file_types] modified to srt,txt
Value for [whisperx][output_file_types] modified to srt
config.json: 100%|█████████████████████████████████| 2.80k/2.80k [00:00<00:00, 9.03MB/s]
vocabulary.txt: 100%|████████████████████████████████| 460k/460k [00:00<00:00, 2.39MB/s]
tokenizer.json: 100%|██████████████████████████████| 2.20M/2.20M [00:00<00:00, 4.40MB/s]
model.bin:   0%|                                            | 0.00/3.09G [00:00<?, ?B/s]
model.bin:   0%|                                   | 10.5M/3.09G [00:00<01:43, 29.7MB/s]
model.bin: 100%|███████████████████████████████████| 3.09G/3.09G [01:42<00:00, 30.0MB/s]
Traceback (most recent call last):
  File "/home/magnus/xx/audiotext/src/controllers/main_controller.py", line 223, in _handle_transcription_process
    await self._transcribe_file(self.transcription.audio_source_path)
  File "/home/magnus/xx/audiotext/src/controllers/main_controller.py", line 292, in _transcribe_file
    self.save_transcription(
  File "/home/magnus/xx/audiotext/src/controllers/main_controller.py", line 137, in save_transcription
    self._whisperx_handler.save_transcription(
  File "/home/magnus/xx/audiotext/src/handlers/whisperx_handler.py", line 115, in save_transcription
    self._whisperx_result["language"] = "en"  # type: ignore[index]
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
TypeError: 'NoneType' object does not support item assignment

Any clue?

@HenestrosaDev
Copy link
Owner

I've tried generating transcriptions with many different configurations (using GPU, CPU, different batch sizes, compute types, and output file types) and have not been able to reproduce it. Can you provide a screenshot including the advanced options? Also, would it be possible to provide the audio for debugging?

@HenestrosaDev
Copy link
Owner

Well, I did get this error:

$ python src/app.py
Traceback (most recent call last):
  File "/home/magnus/xx/audiotext/src/app.py", line 86, in <module>
    app = App()
          ^^^^^
  File "/home/magnus/xx/audiotext/src/app.py", line 26, in __init__
    self.wm_iconbitmap(ph.ROOT_PATH / ph.IMG_RELATIVE_PATH / "icon.ico")
  File "/home/magnus/xx/audiotext/venv/lib/python3.12/site-packages/customtkinter/windows/ctk_tk.py", line 228, in wm_iconbitmap
    super().wm_iconbitmap(bitmap, default)
  File "/usr/lib/python3.12/tkinter/__init__.py", line 2156, in wm_iconbitmap
    return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_tkinter.TclError: bitmap "/home/magnus/xx/audiotext/res/img/icon.ico" not defined

So I edited: audiotext/venv/lib/python3.12/site-packages/customtkinter/windows/ctk_tk.py

and commented out:

    def wm_iconbitmap(self, bitmap=None, default=None):
        self._iconbitmap_method_called = True
#        super().wm_iconbitmap(bitmap, default)

..and the program started.

I selected an mkv file with english audio (english is selected, WhisperX, srt, gpu found, nothing else changed), and when clicking on "Generate transcription", I get this: TypeError("'NoneType' object does not support item assignment")

In the terminal I can see:

$ python src/app.py
Value for [whisperx][can_use_gpu] modified to True
Value for [transcription][audio_source] modified to File
Value for [whisperx][output_file_types] modified to srt,txt
Value for [whisperx][output_file_types] modified to srt
config.json: 100%|█████████████████████████████████| 2.80k/2.80k [00:00<00:00, 9.03MB/s]
vocabulary.txt: 100%|████████████████████████████████| 460k/460k [00:00<00:00, 2.39MB/s]
tokenizer.json: 100%|██████████████████████████████| 2.20M/2.20M [00:00<00:00, 4.40MB/s]
model.bin:   0%|                                            | 0.00/3.09G [00:00<?, ?B/s]
model.bin:   0%|                                   | 10.5M/3.09G [00:00<01:43, 29.7MB/s]
model.bin: 100%|███████████████████████████████████| 3.09G/3.09G [01:42<00:00, 30.0MB/s]
Traceback (most recent call last):
  File "/home/magnus/xx/audiotext/src/controllers/main_controller.py", line 223, in _handle_transcription_process
    await self._transcribe_file(self.transcription.audio_source_path)
  File "/home/magnus/xx/audiotext/src/controllers/main_controller.py", line 292, in _transcribe_file
    self.save_transcription(
  File "/home/magnus/xx/audiotext/src/controllers/main_controller.py", line 137, in save_transcription
    self._whisperx_handler.save_transcription(
  File "/home/magnus/xx/audiotext/src/handlers/whisperx_handler.py", line 115, in save_transcription
    self._whisperx_result["language"] = "en"  # type: ignore[index]
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^
TypeError: 'NoneType' object does not support item assignment

Any clue?

Fixed in #59

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants