pythonwindowsvisual-c++ctypeswhisper

Method find_msvcrt in ctype library is returning None because of the version of msvc that python was compiled


I am using a program which uses the library whisper which uses the ctypes library, to transcribe some video audios. I tested in a virtual machine with windows server already configured, and it works well. The difference between my real machine and the virtual machine is in my real machine I installed Python by its website and in virtual machine I installed using conda, but I think Python has already installed in this VM, and I really don't know which version I was using. I can't check because some few weeks ago I deleted this VM image.

When I debug the code, in the method find_library() located in ctypes.util, it checks the compiler version of MSVC that Python was compiled with and returns the MSVC DLL path, and Python 3.12 is compiled with MSVC 14.3, but the method only supports MSVC <= 13, then, if the version is greater, it will return a None value. I've already tried to force other versions, but it crashes in another part. When the None value is returned, the next method will allocate the MSVC DLL library to an object, but it doesn't work because my path is None value, and crash the program with the following message:

C:/Python312/python.exe e:/Repositories/easy-subber/main.py
Traceback (most recent call last):
  File "e:\Repositories\easy-subber\main.py", line 7, in <module>
    from transcription import transcribe_audio
  File "e:\Repositories\easy-subber\transcription.py", line 1, in <module>
    import whisper
  File "C:\Python312\Lib\site-packages\whisper.py", line 69, in <module>  
    libc = ctypes.CDLL(libc_name)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python312\Lib\ctypes\__init__.py", line 369, in __init__       
    if '/' in name or '\\' in name:
       ^^^^^^^^^^^
TypeError: argument of type 'NoneType' is not iterable

I am using Windows 10, python 3.12 and this program: https://github.com/ignabelitzky/easy-subber

I tested in Ubuntu last version, it works well, but the target machine that I need to run is Windows.

Has someone had this problem and solved this?


Solution

  • 😅
    Took me a while, but:

    [GitHub]: ignabelitzky/easy-subber - EasySubber depends on [GitHub]: openai/whisper - Whisper which states (emphasis is mine):

    pip install -U openai-whisper (that installs [PyPI]: openai-whisper).

    Instead, you have [PyPI]: whisper (most likely installed by (a variant of): pip install whisper).

    Install the right package and you should be fine (probably the other one is for Nix only?).