cmusphinx / pocketsphinx

A small speech recognizer
Other
3.9k stars 714 forks source link

Error while installing on Raspberry Pi Zero 2W #394

Closed rpatapa closed 1 day ago

rpatapa commented 1 week ago

pizero2w:~ $ pip3 install pocketsphinx

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting pocketsphinx Using cached pocketsphinx-5.0.3.tar.gz (34.1 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing wheel metadata ... done Collecting sounddevice Using cached https://www.piwheels.org/simple/sounddevice/sounddevice-0.5.0-py3-none-any.whl (32 kB) Collecting CFFI>=1.0 Using cached cffi-1.17.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (447 kB) Collecting pycparser Using cached https://www.piwheels.org/simple/pycparser/pycparser-2.22-py3-none-any.whl (117 kB) Building wheels for collected packages: pocketsphinx Building wheel for pocketsphinx (PEP 517) ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python3 /tmp/tmpnx0ody_o_in_process.py build_wheel /tmp/tmpq_ftjmkg cwd: /tmp/pip-install-62_fbod8/pocketsphinx_d172b17683d240a7ab69c093c14cba55 Complete output (27 lines): WARNING: Minimum CMake version set as 'CMakeLists.txt' is less than 3.15. This is not supported by scikit-build-core; set manually or increase to avoid this warning. WARNING: Use build.verbose instead of cmake.verbose for scikit-build-core >= 0.10 2024-09-10 11:33:15,458 - scikit_build_core - INFO - RUN: /tmp/pip-build-env-t1iqgoh3/normal/lib/python3.9/site-packages/cmake/data/bin/cmake -E capabilities 2024-09-10 11:33:15,487 - scikit_build_core - INFO - CMake version: 3.30.3 scikit-build-core 0.10.5 using CMake 3.30.3 (wheel) 2024-09-10 11:33:15,526 - scikit_build_core - INFO - Build directory: /tmp/tmpe44f9fot/build Configuring CMake... 2024-09-10 11:33:15,669 - scikit_build_core - INFO - RUN: /tmp/pip-build-env-t1iqgoh3/normal/lib/python3.9/site-packages/ninja/data/bin/ninja --version 2024-09-10 11:33:15,707 - scikit_build_core - INFO - Ninja version: 1.11.1 Traceback (most recent call last): File "/tmp/tmpnx0ody_o_in_process.py", line 280, in main() File "/tmp/tmpnx0ody_o_in_process.py", line 263, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/tmp/tmpnx0ody_o_in_process.py", line 204, in build_wheel return _build_backend().build_wheel(wheel_directory, config_settings, File "/tmp/pip-build-env-t1iqgoh3/overlay/lib/python3.9/site-packages/scikit_build_core/build/init.py", line 31, in build_wheel return _build_wheel_impl( File "/tmp/pip-build-env-t1iqgoh3/overlay/lib/python3.9/site-packages/scikit_build_core/build/wheel.py", line 175, in _build_wheel_impl return _build_wheel_impl_impl( File "/tmp/pip-build-env-t1iqgoh3/overlay/lib/python3.9/site-packages/scikit_build_core/build/wheel.py", line 402, in _build_wheel_impl_impl builder.configure( File "/tmp/pip-build-env-t1iqgoh3/overlay/lib/python3.9/site-packages/scikit_build_core/builder/builder.py", line 189, in configure numpy_include_dir = get_numpy_include_dir() File "/tmp/pip-build-env-t1iqgoh3/overlay/lib/python3.9/site-packages/scikit_build_core/builder/sysconfig.py", line 197, in get_numpy_include_dir return Path(np.get_include()) AttributeError: module 'numpy' has no attribute 'get_include'


ERROR: Failed building wheel for pocketsphinx Failed to build pocketsphinx ERROR: Could not build wheels for pocketsphinx which use PEP 517 and cannot be installed directly

dhdaines commented 1 week ago

Hi, thanks for the report - do you think I would be able to reproduce this problem on a Pi 5?

It seems like it could be a bug in scikit-build-core, or possibly a version of numpy that is out of date.

rpatapa commented 1 week ago

Hi,

Sorry I did not explicitly mention that I was using Pi Zero 2W. I don't have a Pi 5. I upgraded numpy with pip3 install --upgrade --force-reinstall numpy But the error while installing pocketsphinx is same. Can we install pocketsphinx on Pi Zero 2W?

pizero:~ $ pip3 install --upgrade --force-reinstall numpy Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting numpy Using cached numpy-2.0.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (13.9 MB) Installing collected packages: numpy Attempting uninstall: numpy Found existing installation: numpy 1.22.0 Uninstalling numpy-1.22.0: Successfully uninstalled numpy-1.22.0 WARNING: The scripts f2py and numpy-config are installed in '/home/aneka/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts. efficientword-net 1.0.2 requires numpy==1.22.0, but you have numpy 2.0.2 which is incompatible. Successfully installed numpy-2.0.2 pizero:~ $ pip3 install --upgrade pocketsphinx Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: pocketsphinx in /usr/lib/python3/dist-packages (0.1.15) Collecting pocketsphinx Using cached pocketsphinx-5.0.3.tar.gz (34.1 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing wheel metadata ... done Requirement already satisfied: sounddevice in ./.local/lib/python3.9/site-packages (from pocketsphinx) (0.5.0) Requirement already satisfied: CFFI>=1.0 in ./.local/lib/python3.9/site-packages (from sounddevice->pocketsphinx) (1.17.1) Requirement already satisfied: pycparser in ./.local/lib/python3.9/site-packages (from CFFI>=1.0->sounddevice->pocketsphinx) (2.22) Building wheels for collected packages: pocketsphinx Building wheel for pocketsphinx (PEP 517) ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python3 /tmp/tmp0u3bkb1q_in_process.py build_wheel /tmp/tmpvbe51qey cwd: /tmp/pip-install-z_cornju/pocketsphinx_cfc13a925ca4445185c02544f8103313 Complete output (27 lines): WARNING: Minimum CMake version set as 'CMakeLists.txt' is less than 3.15. This is not supported by scikit-build-core; set manually or increase to avoid this warning. WARNING: Use build.verbose instead of cmake.verbose for scikit-build-core >= 0.10 2024-09-10 18:47:46,880 - scikit_build_core - INFO - RUN: /tmp/pip-build-env-yfaid953/normal/lib/python3.9/site-packages/cmake/data/bin/cmake -E capabilities 2024-09-10 18:47:46,909 - scikit_build_core - INFO - CMake version: 3.30.3 scikit-build-core 0.10.5 using CMake 3.30.3 (wheel) 2024-09-10 18:47:46,948 - scikit_build_core - INFO - Build directory: /tmp/tmp8tpfkh3u/build Configuring CMake... 2024-09-10 18:47:47,741 - scikit_build_core - INFO - RUN: /tmp/pip-build-env-yfaid953/normal/lib/python3.9/site-packages/ninja/data/bin/ninja --version 2024-09-10 18:47:47,762 - scikit_build_core - INFO - Ninja version: 1.11.1 Traceback (most recent call last): File "/tmp/tmp0u3bkb1q_in_process.py", line 280, in main() File "/tmp/tmp0u3bkb1q_in_process.py", line 263, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/tmp/tmp0u3bkb1q_in_process.py", line 204, in build_wheel return _build_backend().build_wheel(wheel_directory, config_settings, File "/tmp/pip-build-env-yfaid953/overlay/lib/python3.9/site-packages/scikit_build_core/build/init.py", line 31, in build_wheel return _build_wheel_impl( File "/tmp/pip-build-env-yfaid953/overlay/lib/python3.9/site-packages/scikit_build_core/build/wheel.py", line 175, in _build_wheel_impl return _build_wheel_impl_impl( File "/tmp/pip-build-env-yfaid953/overlay/lib/python3.9/site-packages/scikit_build_core/build/wheel.py", line 402, in _build_wheel_impl_impl builder.configure( File "/tmp/pip-build-env-yfaid953/overlay/lib/python3.9/site-packages/scikit_build_core/builder/builder.py", line 189, in configure numpy_include_dir = get_numpy_include_dir() File "/tmp/pip-build-env-yfaid953/overlay/lib/python3.9/site-packages/scikit_build_core/builder/sysconfig.py", line 197, in get_numpy_include_dir return Path(np.get_include()) AttributeError: module 'numpy' has no attribute 'get_include'


ERROR: Failed building wheel for pocketsphinx Failed to build pocketsphinx ERROR: Could not build wheels for pocketsphinx which use PEP 517 and cannot be installed directly

dhdaines commented 1 week ago

Right, I have a Pi 5, that's why I'm asking :) if it's the same OS then it should be the same problem. It looks like it is: https://www.raspberrypi.com/software/operating-systems/

Do you know what version of Raspberry Pi OS you are using?

dhdaines commented 1 week ago

I'll try testing this when I get a moment (possibly later today).

rpatapa commented 1 week ago

Thanks for looking into this..

I was using Legacy 64bit Lite Debian Bullseye

rpatapa commented 6 days ago

Further to force upgrading numpy, I updated CMake also to 3.30.0.

The error remains:

pizero:~ $ pip3 install pocketsphinx

_Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting pocketsphinx Using cached pocketsphinx-5.0.3.tar.gz (34.1 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing wheel metadata ... done Requirement already satisfied: sounddevice in ./.local/lib/python3.9/site-packages (from pocketsphinx) (0.5.0) Requirement already satisfied: CFFI>=1.0 in ./.local/lib/python3.9/site-packages (from sounddevice->pocketsphinx) (1.17.1) Requirement already satisfied: pycparser in ./.local/lib/python3.9/site-packages (from CFFI>=1.0->sounddevice->pocketsphinx) (2.22) Building wheels for collected packages: pocketsphinx Building wheel for pocketsphinx (PEP 517) ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python3 /tmp/tmpusg8x6_r_in_process.py build_wheel /tmp/tmp53ghoc8o cwd: /tmp/pip-install-n80lblhc/pocketsphinx_46a11b337e4f42868dee4562b9a1be9e Complete output (27 lines): WARNING: Minimum CMake version set as 'CMakeLists.txt' is less than 3.15. This is not supported by scikit-build-core; set manually or increase to avoid this warning. WARNING: Use build.verbose instead of cmake.verbose for scikit-build-core >= 0.10 2024-09-11 22:59:51,409 - scikit_build_core - INFO - RUN: /usr/local/bin/cmake -E capabilities 2024-09-11 22:59:51,446 - scikit_build_core - INFO - CMake version: 3.30.0 scikit-build-core 0.10.6 using CMake 3.30.0 (wheel) 2024-09-11 22:59:51,481 - scikit_build_core - INFO - Build directory: /tmp/tmp0d3i4tvi/build Configuring CMake... 2024-09-11 22:59:51,605 - scikit_build_core - INFO - RUN: /tmp/pip-build-env-zlca410t/normal/lib/python3.9/site-packages/ninja/data/bin/ninja --version 2024-09-11 22:59:51,625 - scikit_build_core - INFO - Ninja version: 1.11.1 Traceback (most recent call last): File "/tmp/tmpusg8x6_r_in_process.py", line 280, in main() File "/tmp/tmpusg8x6_r_in_process.py", line 263, in main json_out['return_val'] = hook(**hook_input['kwargs']) File "/tmp/tmpusg8x6_r_in_process.py", line 204, in build_wheel return _build_backend().build_wheel(wheel_directory, config_settings, File "/tmp/pip-build-env-zlca410t/overlay/lib/python3.9/site-packages/scikit_build_core/build/init.py", line 31, in build_wheel return _build_wheel_impl( File "/tmp/pip-build-env-zlca410t/overlay/lib/python3.9/site-packages/scikit_build_core/build/wheel.py", line 175, in _build_wheel_impl return _build_wheel_impl_impl( File "/tmp/pip-build-env-zlca410t/overlay/lib/python3.9/site-packages/scikit_build_core/build/wheel.py", line 402, in _build_wheel_impl_impl builder.configure( File "/tmp/pip-build-env-zlca410t/overlay/lib/python3.9/site-packages/scikit_build_core/builder/builder.py", line 207, in configure numpy_include_dir = get_numpy_include_dir() File "/tmp/pip-build-env-zlca410t/overlay/lib/python3.9/site-packages/scikit_build_core/builder/sysconfig.py", line 197, in get_numpy_include_dir return Path(np.get_include()) AttributeError: module 'numpy' has no attribute 'getinclude' ----------------------------------------

ERROR: Failed building wheel for pocketsphinx Failed to build pocketsphinx ERROR: Could not build wheels for pocketsphinx which use PEP 517 and cannot be installed directly

dhdaines commented 6 days ago

Hm. okay. If you run pip freeze | grep numpy what version does it tell you?

rpatapa commented 5 days ago

pizero:~ $ pip freeze | grep numpy numpy==2.0.2 pizero:~ $

dhdaines commented 5 days ago

Hm, unfortunately I can't reproduce this on my Pi5. This is certainly due to having a more recent version of, well, everything (I have the latest OS, bookworm-based). Here are what I think are the relevant versions:

Two things:

  1. Can you install in a virtualenv? That way we know what the dependencies are...
  2. Are you able to update to the most recent Raspberry Pi OS?

Alternately I can try flashing the legacy OS to see if I can reproduce the problem that way.

dhdaines commented 5 days ago

Nope, legacy OS is not compatible with Raspberry Pi 5. Sorry...

rpatapa commented 4 days ago

BTW, is pocketsphinx 5.0.3 compatible with Python 3.9.x?

dhdaines commented 4 days ago

Yes, at least on x86-64 it builds and works fine. As a last thing to try, you could perhaps try building, in a virtualenv, without build isolation:

python -m venv .venv
source .venv/bin/activate
pip install numpy cython scikit-build-core cmake ninja
pip install -v --no-build-isolation pocketsphinx

What happens when you do that?

rpatapa commented 4 days ago

In an environment, I was able to install. Simple pip install pocketsphix also could install successfully!

dhdaines commented 4 days ago

Great! Something is just not quite right with the system install of Python on the legacy PiOS I guess ... it's nearly always a better idea to install in a virtualenv, and now I have another reason why :) Thanks for your patience!

rpatapa commented 1 day ago

Much appreciate your support! Thank you!

dhdaines commented 1 day ago

I'll close the issue but it will remain visible/searchable if anyone else has the same issue, glad there's a workaround.