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

ModuleNotFoundError: No module named 'keyboard' #41

Open
Patrickvdh opened this issue May 12, 2024 · 8 comments
Open

ModuleNotFoundError: No module named 'keyboard' #41

Patrickvdh opened this issue May 12, 2024 · 8 comments

Comments

@Patrickvdh
Copy link

Hello,

I try to run whisper-writer, but this message comes up : ModuleNotFoundError: No module named 'keyboard'

pv@portpat:~/whisper-writer$ python3 run.py
Starting WhisperWriter...
Traceback (most recent call last):
File "/home/pv/whisper-writer/src/main.py", line 6, in
import keyboard
ModuleNotFoundError: No module named 'keyboard'

Any idea to help ?

thanks, patrick

@savbell
Copy link
Owner

savbell commented May 12, 2024

Hi Patrick,

Did you follow all the directions in the Installation part of the Readme, including creating and activating a virtual Python environment?

My guess would be you haven't run the command pip install -r requirements.txt. This should install all the required Python modules, including keyboard.

Please let me know if you have followed all the directions and run all the commands and are still encountering this issue. If that's the case, please also let me know what platform you are running WhisperWriter on and which version of Python you are using.

Thanks,
Sav

@Patrickvdh
Copy link
Author

Hi Savbell,
Thanks for your answer.
I've been trough all installation procedure.
When running pip install -r requirements.txt, an error occured :

ERROR: Cannot install -r requirements.txt (line 14) and av==10.0.0 because these package versions have conflicting dependencies.

The conflict is caused by:
The user requested av==10.0.0
faster-whisper 0.10.0 depends on av==11.*

Any suggestion ? thanks, patrick
Ubuntu 22.04

@savbell
Copy link
Owner

savbell commented May 14, 2024

Hi Patrick,

Thanks for your response! What you're encountering is an error that has since been fixed in the latest commits. Try running git pull to update requirements.txt to the latest version (it should look like this, with av==11.0.0 on line 8). Then try running pip install -r requirements.txt again and let me know if that works!

Cheers,
Sav

@Patrickvdh
Copy link
Author

Hi Sav,
thanks for your help.

Pip install -r requirements.txt report this warning :

WARNING: Generating metadata for package evdev produced metadata for project name unknown. Fix your #egg=evdev fragments.
Discarding https://files.pythonhosted.org/packages/12/bb/f622a8a5e64d46ca83020a761877c0ead19140903c9aaf1431f3c531fdf6/evdev-1.7.1.tar.gz#sha256=0c72c370bda29d857e188d931019c32651a9c1ea977c08c8d939b1ced1637fde (from https://pypi.org/simple/evdev/) (requires-python:>=3.6): Requested unknown from https://files.pythonhosted.org/packages/12/bb/f622a8a5e64d46ca83020a761877c0ead19140903c9aaf1431f3c531fdf6/evdev-1.7.1.tar.gz#sha256=0c72c370bda29d857e188d931019c32651a9c1ea977c08c8d939b1ced1637fde (from pynput==1.7.6->-r requirements.txt (line 53)) has inconsistent name: filename has 'evdev', but metadata has 'unknown'
Downloading evdev-1.7.0.tar.gz (30 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
WARNING: Generating metadata for package evdev produced metadata for project name unknown. Fix your #egg=evdev fragments.
Discarding https://files.pythonhosted.org/packages/f3/0c/c87b141250a650ee53d4e9957e905b17c144cda6dc4187cbe89a641a1b34/evdev-1.7.0.tar.gz#sha256=95bd2a1e0c6ce2cd7a2ecc6e6cd9736ff794b3ad5cb54d81d8cbc2e414d0b870 (from https://pypi.org/simple/evdev/) (requires-python:>=3.6): Requested unknown from https://files.pythonhosted.org/packages/f3/0c/c87b141250a650ee53d4e9957e905b17c144cda6dc4187cbe89a641a1b34/evdev-1.7.0.tar.gz#sha256=95bd2a1e0c6ce2cd7a2ecc6e6cd9736ff794b3ad5cb54d81d8cbc2e414d0b870 (from pynput==1.7.6->-r requirements.txt (line 53)) has inconsistent name: filename has 'evdev', but metadata has 'unknown'
Downloading evdev-1.6.1.tar.gz (26 kB)
Preparing metadata (setup.py) ... done

Then when running python3 run.py

Starting WhisperWriter...
Traceback (most recent call last):
File "/home/pv/whisper-writer/src/main.py", line 9, in
from transcription import create_local_model, record_and_transcribe
File "/home/pv/whisper-writer/src/transcription.py", line 4, in
import sounddevice as sd
File "/home/pv/.local/lib/python3.10/site-packages/sounddevice.py", line 71, in
raise OSError('PortAudio library not found')
OSError: PortAudio library not found

Sorry not to be able to understand these.
Any idea to sole it ?

thanks, patrick

@savbell
Copy link
Owner

savbell commented May 14, 2024

Hi Patrick,

It looks like the error is indicating the PortAudio library is either not installed or can't be found. You can try installing the PortAudio development package:

sudo apt update
sudo apt install libportaudio2 libportaudiocpp0 portaudio19-dev

And then reinstalling sounddevice:

pip uninstall sounddevice
pip install sounddevice

Hopefully that resolves your issue! Please let me know if it doesn't.

Thanks,
Sav

@Patrickvdh
Copy link
Author

Hi Sav,

I encounter this error after pip install -r requirements.txt :

Using cached lit-18.1.4-py3-none-any.whl (96 kB)
Building wheels for collected packages: evdev
Building wheel for evdev (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for evdev (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [40 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-311
creating build/lib.linux-x86_64-cpython-311/evdev
copying evdev/events.py -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/eventio_async.py -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/util.py -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/device.py -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/ff.py -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/eventio.py -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/ecodes.py -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/init.py -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/evtest.py -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/genecodes.py -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/uinput.py -> build/lib.linux-x86_64-cpython-311/evdev
running egg_info
writing evdev.egg-info/PKG-INFO
writing dependency_links to evdev.egg-info/dependency_links.txt
writing top-level names to evdev.egg-info/top_level.txt
reading manifest file 'evdev.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files found matching 'evdev/ecodes.c'
adding license file 'LICENSE'
writing manifest file 'evdev.egg-info/SOURCES.txt'
copying evdev/input.c -> build/lib.linux-x86_64-cpython-311/evdev
copying evdev/uinput.c -> build/lib.linux-x86_64-cpython-311/evdev
running build_ext
running build_ecodes
writing /tmp/pip-install-5zq7t9ic/evdev_874eb02d26c04a93a07de4a82f4080e3/evdev/ecodes.c (using /usr/include/linux/input.h /usr/include/linux/input-event-codes.h /usr/include/linux/uinput.h)
building 'evdev._input' extension
creating build/temp.linux-x86_64-cpython-311
creating build/temp.linux-x86_64-cpython-311/evdev
x86_64-linux-gnu-gcc -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/pv/whisper-writer/venv/include -I/usr/include/python3.11 -c evdev/input.c -o build/temp.linux-x86_64-cpython-311/evdev/input.o -std=c99 -Wno-error=declaration-after-statement
evdev/input.c:10:10: fatal error: Python.h: Aucun fichier ou dossier de ce nom
10 | #include <Python.h>
| ^~~~~~~~~~
compilation terminated.
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for evdev
Failed to build evdev
ERROR: Could not build wheels for evdev, which is required to install pyproject.toml-based projects

Thanks for any suggestion,
patrick

@savbell
Copy link
Owner

savbell commented May 19, 2024

Hi Patrick,

I'm sorry you're running into so many errors trying to install the packages! This error seems to be due to a missing Python.h header file. It may not be installed on your system, in which case the solution would be to install the Python development headers:

sudo apt-get install python3-dev

And then you can try installing the packages again. I hope that helps!

Cheers,
Sav

@siddAhmed
Copy link

Hi Patrick,

It looks like the error is indicating the PortAudio library is either not installed or can't be found. You can try installing the PortAudio development package:

sudo apt update
sudo apt install libportaudio2 libportaudiocpp0 portaudio19-dev

And then reinstalling sounddevice:

pip uninstall sounddevice
pip install sounddevice

Hopefully that resolves your issue! Please let me know if it doesn't.

Thanks, Sav

Hey,
I am getting the same error for missing the PortAudio library but in Windows 10.
My python version is 3.12 and numba (requirements.txt) requires a version <3.12, hence it wouldn't install.

...
Collecting numba==0.57.0 (from -r requirements.txt (line 40))
  Downloading numba-0.57.0.tar.gz (2.5 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.5/2.5 MB 4.3 MB/s eta 0:00:00
  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
  ╰─> [21 lines of output]
      Traceback (most recent call last):
        File "C:\Program Files\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Program Files\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Program Files\Python312\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Ahmed Siddiqui\AppData\Local\Temp\pip-build-env-hk1l7p6h\overlay\Lib\site-packages\setuptools\build_meta.py", line 327, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Ahmed Siddiqui\AppData\Local\Temp\pip-build-env-hk1l7p6h\overlay\Lib\site-packages\setuptools\build_meta.py", line 297, in _get_build_requires
          self.run_setup()
        File "C:\Users\Ahmed Siddiqui\AppData\Local\Temp\pip-build-env-hk1l7p6h\overlay\Lib\site-packages\setuptools\build_meta.py", line 497, in run_setup
          super().run_setup(setup_script=setup_script)
        File "C:\Users\Ahmed Siddiqui\AppData\Local\Temp\pip-build-env-hk1l7p6h\overlay\Lib\site-packages\setuptools\build_meta.py", line 313, in run_setup
          exec(code, locals())
        File "<string>", line 51, in <module>
        File "<string>", line 48, in _guard_py_ver
      RuntimeError: Cannot install on Python version 3.12.1; only versions >=3.8,<3.12 are supported.
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

So I created a virtual environment with Python 3.10 using uv, an "extremely fast Python package installer and resolver" and then I could install all the requirements. However, I'm still missing the PortAudio library and there doesn't seem to be a straightforward way to install it on windows. Any clues on how to fix this?

➜ python run.py
Starting WhisperWriter...
Traceback (most recent call last):
  File "C:\dev\whisper-writer\.venv\lib\site-packages\sounddevice.py", line 71, in <module>
    raise OSError('PortAudio library not found')
OSError: PortAudio library not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\dev\whisper-writer\src\main.py", line 10, in <module>
    from result_thread import ResultThread
  File "C:\dev\whisper-writer\src\result_thread.py", line 4, in <module>
    import sounddevice as sd
  File "C:\dev\whisper-writer\.venv\lib\site-packages\sounddevice.py", line 80, in <module>
    import _sounddevice_data
ModuleNotFoundError: No module named '_sounddevice_data'

System Information:

OS Name:                   Microsoft Windows 10 Pro
OS Version:                10.0.19044 N/A Build 19044

Python: 3.12.1 (system), 3.10.8 (virtual environment)
Package manager: uv 0.1.3
Cuda: release 12.4, V12.4.131

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

3 participants