savbell / whisper-writer

💬📝 A small dictation app using OpenAI's Whisper speech recognition model.
GNU General Public License v3.0
244 stars 40 forks source link

ModuleNotFoundError: No module named 'keyboard' #41

Open Patrickvdh opened 2 months ago

Patrickvdh commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 2 months ago

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 commented 1 month ago

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 | ^~~~~~ 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 commented 1 month ago

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