用Buildoz进行语音识别

2024-10-02 22:28:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在为android编写一个应用程序,在那里我使用SpeachRecognition库使用googleapi将语音转换成文本。 我的程序可以在Ubuntu16.04Python3.5上使用KivyGUI,那么如何使用buildozer构建这个应用程序呢?要求是什么? 我已在中修改了要求buildozer.spec变成:“requirements=kivy,hostpython2,SpeechRecognition,pyaudio”,但这会引发以下错误:“pyaudio的构建轮失败”。在

编辑:(命令“Buildozer android debug”的一部分输出)

[信息]:#安装纯Python模块

[INFO]: The requirements (SpeechRecognition, pyaudio) don't have recipes, attempting to install them with pip

[INFO]: If this fails, it may mean that the module has compiled components and needs a recipe.

[INFO]: -> directory context /home/proctronics/Desktop/test/.buildozer/android/platform/build/build

[INFO]: -> running virtualenv --python=python2.7 venv

objs_paths are ['/home/proctronics/Desktop/test/.buildozer/android/platform/build/build/bootstrap_builds/sdl2-python2/collated_objects']

Copying libraries

[INFO]: Creating a requirements.txt file for the Python modules

[INFO]: Installing Python modules with pip

[INFO]: If this fails with a message about /bin/false, this probably means the package cannot be installed with pip as it needs a compilation recipe.

[INFO]: -> running bash -c source venv/bin/activate && env CC=/bin/false CXX=/bin/false PYTHONPATH=/home/proctronics/Desktop/test/.b...(and 259 more)

working: Exception in thread background thread for pid 3095:n/python2.7 -u -c "import setupt...(and 509 more)

Traceback (most recent call last):

File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner

self.run()

File "/usr/lib/python2.7/threading.py", line 754, in run

self.__target(*self.__args, **self.__kwargs)

File "/home/proctronics/.local/lib/python2.7/site-packages/sh.py", line 1540, in wrap

fn(*args, **kwargs)

File "/home/proctronics/.local/lib/python2.7/site-packages/sh.py", line 2459, in background_thread

handle_exit_code(exit_code)

File "/home/proctronics/.local/lib/python2.7/site-packages/sh.py", line 2157, in fn

return self.command.handle_command_exit_code(exit_code)

File "/home/proctronics/.local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code

raise exc

ErrorReturnCode_1:

RAN: /bin/bash -c source venv/bin/activate && env CC=/bin/false CXX=/bin/false PYTHONPATH=/home/proctronics/Desktop/test/.buildozer/android/platform/build/build/python-installs/blue/lib/python2.7/site-packages pip install --target '/home/proctronics/Desktop/test/.buildozer/android/platform/build/build/python-installs/blue/lib/python2.7/site-packages' --no-deps -r requirements.txt

STDOUT:

Collecting SpeechRecognition (from -r requirements.txt (line 1))

Using cached SpeechRecognition-3.7.1-py2.py3-none-any.whl

Collecting pyaudio (from -r requirements.txt (line 2))

Using cached PyAudio-0.2.11.tar.gz

Building wheels for collected packages: pyaudio

Running setup.py bdist_wheel for pyaudio ... error

Complete output from command /home/proctronics/Desktop/test/.buildozer/android/platform/build/build/venv/bin/python2.7 -u -c "import setuptools, tokenize;file='/tmp/pip-build-QShDtG/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('

', '

');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/tmp9IBfgPpip-wheel- --python-tag cp27:

running bdist_wheel

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

copying src/pyaudio.py -> build/lib.linux-x86_64-2.7

running build_ext

building '_portaudio' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

/bin/false -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o

error: command '/bin/false' failed with exit status 1


Failed building wheel for pyaudio

Running setup.py clean for pyaudio

Failed to build pyaudio

Installing collected packages: SpeechRecognition, pyaudio

Running setup.py install for pyaudio ... error

Complete output from command /home/proctronics/Desktop/test/.buildozer/android/platform/build/build/venv/bin/python2.7 -u -c "import setuptools, tokenize;file='/tmp/pip-build-QShDtG/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('

', '

');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-ObcFB4-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/proctronics/Desktop/test/.buildozer/android/platform/build/build/venv/include/site/python2.7/pyaudio --home=/tmp/tmp93Wh_5:

running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

copying src/pyaudio.py -> build/lib.linux-x86_64-2.7

running build_ext

building '_portaudio' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

/bin/false -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o

error: command '/bin/false' failed with exit status 1


Command "/home/proctronics/Desktop/test/.buildozer/android/platform/build/build/venv/bin/python2.7 -u -c "import setuptools, tokenize;file='/tmp/pip-build-QShDtG/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('

', '

');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-ObcFB4-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/proctronics/Desktop/test/.buildozer/android/platform/build/build/venv/include/site/python2.7/pyaudio --home=/tmp/tmp93Wh_5" failed with error code 1 in /tmp/pip-build-QShDtG/pyaudio/

STDERR:

Traceback (most recent call last):

File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main

"main", fname, loader, pkg_name)

File "/usr/lib/python2.7/runpy.py", line 72, in _run_code

exec code in run_globals

File "/home/proctronics/Desktop/test/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 905, in

main()

File "/home/proctronics/Desktop/test/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 902, in main

ToolchainCL()

File "/home/proctronics/Desktop/test/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 508, in init

getattr(self, args.subparser_name.replace('-', '_'))(args)

File "/home/proctronics/Desktop/test/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 147, in wrapper_func

build_dist_from_args(ctx, dist, args)

File "/home/proctronics/Desktop/test/.buildozer/android/platform/python-for-android-master/pythonforandroid/toolchain.py", line 190, in build_dist_from_args

build_recipes(build_order, python_modules, ctx)

File "pythonforandroid/build.py", line 585, in build_recipes

File "pythonforandroid/build.py", line 626, in run_pymodules_install

File "pythonforandroid/logger.py", line 175, in shprint

File "/home/proctronics/.local/lib/python2.7/site-packages/sh.py", line 863, in next

self.wait()

File "/home/proctronics/.local/lib/python2.7/site-packages/sh.py", line 792, in wait

self.handle_command_exit_code(exit_code)

File "/home/proctronics/.local/lib/python2.7/site-packages/sh.py", line 815, in handle_command_exit_code

raise exc

sh.ErrorReturnCode_1:

RAN: /bin/bash -c source venv/bin/activate && env CC=/bin/false CXX=/bin/false PYTHONPATH=/home/proctronics/Desktop/test/.buildozer/android/platform/build/build/python-installs/blue/lib/python2.7/site-packages pip install --target '/home/proctronics/Desktop/test/.buildozer/android/platform/build/build/python-installs/blue/lib/python2.7/site-packages' --no-deps -r requirements.txt

STDOUT:

Collecting SpeechRecognition (from -r requirements.txt (line 1))

Using cached SpeechRecognition-3.7.1-py2.py3-none-any.whl

Collecting pyaudio (from -r requirements.txt (line 2))

Using cached PyAudio-0.2.11.tar.gz

Building wheels for collected packages: pyaudio

Running setup.py bdist_wheel for pyaudio ... error

Complete output from command /home/proctronics/Desktop/test/.buildozer/android/platform/build/build/venv/bin/python2.7 -u -c "import setuptools, tokenize;file='/tmp/pip-build-QShDtG/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('

', '

');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /tmp/tmp9IBfgPpip-wheel- --python-tag cp27:

running bdist_wheel

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

copying src/pyaudio.py -> build/lib.linux-x86_64-2.7

running build_ext

building '_portaudio' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

/bin/false -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o

error: command '/bin/false' failed with exit status 1


Failed building wheel for pyaudio

Running setup.py clean for pyaudio

Failed to build pyaudio

Installing collected packages: SpeechRecognition, pyaudio

Running setup.py install for pyaudio ... error

Complete output from command /home/proctronics/Desktop/test/.buildozer/android/platform/build/build/venv/bin/python2.7 -u -c "import setuptools, tokenize;file='/tmp/pip-build-QShDtG/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('

', '

');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-ObcFB4-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/proctronics/Desktop/test/.buildozer/android/platform/build/build/venv/include/site/python2.7/pyaudio --home=/tmp/tmp93Wh_5:

running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

copying src/pyaudio.py -> build/lib.linux-x86_64-2.7

running build_ext

building '_portaudio' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

/bin/false -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c src/_portaudiomodule.c -o build/temp.linux-x86_64-2.7/src/_portaudiomodule.o

error: command '/bin/false' failed with exit status 1


Command "/home/proctronics/Desktop/test/.buildozer/android/platform/build/build/venv/bin/python2.7 -u -c "import setuptools, tokenize;file='/tmp/pip-build-QShDtG/pyaudio/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('

', '

');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-ObcFB4-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/proctronics/Desktop/test/.buildozer/android/platform/build/build/venv/include/site/python2.7/pyaudio --home=/tmp/tmp93Wh_5" failed with error code 1 in /tmp/pip-build-QShDtG/pyaudio/

STDERR:

Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=blue --bootstrap=sdl2 --requirements=kivy,hostpython2,SpeechRecognition,pyaudio --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/proctronics/Desktop/test/.buildozer/android/platform/build

Buildozer failed to execute the last command

The error might be hidden in the log above this error

Please read the full log, and search for it before

raising an issue with buildozer itself.

In case of a bug report, please add a full log with log_level

提前谢谢。在


Tags: inpytestbuildhomebinlibline
1条回答
网友
1楼 · 发布于 2024-10-02 22:28:45

根据这个link,只有纯python包可以自动安装,所有依赖于二进制编译的包都必须编写一个配方。在

配方是包含要编译的模块的“定义”的脚本。配方的目录布局类似于:

python-for-android/recipes//recipe.sh

python-for-android/recipes//patches/

python-for-android/recipes//patches/fix-path.patch When building, all the recipe build must go to:

python-for-android/build// For example, if you want to create a recipe for sdl, do:

cd python-for-android/recipes mkdir sdl cp recipe.sh.tmpl

sdl/recipe.sh sed -i 's#XXX#sdl#' sdl/recipe.sh Then, edit the

sdl/recipe.sh to adjust other information (version, url) and complete build function.

相关问题 更多 >