Buildozer Numpy RuntimeError:断开的工具链:无法链接简单的C程序 [英] Buildozer Numpy RuntimeError: Broken toolchain: cannot link a simple C program

查看:71
本文介绍了Buildozer Numpy RuntimeError:断开的工具链:无法链接简单的C程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用Python编写我的第一个Android应用程序,并使用Buildozer对其进行打包.因为稍后需要在项目中使用numpy,所以我尝试打包以下测试代码:

Writing my first Android app in Python and using Buildozer to package it. Because I will need to use numpy later on in the project, I tried packaging the following test code:

import numpy
import kivy
kivy.require('1.0.6')
from kivy.app import App
from kivy.uix.button import Button

class TestApp(App):
    def build(self):
        return Button(text='Hello World')

TestApp().run()

但是,出现以下错误:

Traceback (most recent call last):
  File "setup.py", line 251, in <module>
    setup_package()
  File "setup.py", line 243, in setup_package
    setup(**metadata)
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/core.py", line 169, in setup
    return old_setup(**new_attr)
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/command/build_ext.py", line 59, in run
    self.run_command('build_src')
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/cmd.py", line 326, in run_command
    self.distribution.run_command(command)
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/python-installs/myapp/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/command/build_src.py", line 153, in run
    self.build_sources()
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/command/build_src.py", line 164, in build_sources
    self.build_library_sources(*libname_info)
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/command/build_src.py", line 299, in build_library_sources
    sources = self.generate_sources(sources, (lib_name, build_info))
  File "/home/kivy/Desktop/cam/.buildozer/android/platform/build/build/other_builds/numpy/armeabi-v7a/numpy/numpy/distutils/command/build_src.py", line 386, in generate_sources
    source = func(extension, build_dir)
  File "numpy/core/setup.py", line 686, in get_mathlib_info
    raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program


  STDERR:
# Command failed: /usr/bin/python -m pythonforandroid.toolchain create --dist_name=myapp --bootstrap=sdl2 --requirements=kivy,numpy --arch armeabi-v7a --copy-libs --color=always --storage-dir=/home/kivy/Desktop/cam/.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 = 2

另外,这是我的buildozer.spec文件:

title = My Application
package.name = myapp
package.domain = org.test
source.dir = .
source.include_exts = py,png,jpg,kv,atlas
version = 1.0

requirements = kivy,numpy

orientation = portrait
osx.kivy_version = 1.9.1
fullscreen = 0
android.api = 19
android.sdk = 20
android.ndk = 9c
android.arch = armeabi-v7a
log_level = 2
warn_on_root = 1

请注意,当我从python代码中删除"import numpy"并从buildozer.spec文件的需求列表中删除了"numpy"时,我的代码被完美打包了.我在预先安装了Buildozer的VM Virtual Box上运行此程序.

Note that when I removed "import numpy" from the python code and removed "numpy" from the requirements list in the buildozer.spec file, my code was packaged perfectly. I am running this on VM Virtual Box which had Buildozer pre-installed.

这不仅仅是Numpy给我的问题-OpenCV给了我完全相同的错误.如有需要,将为此单独发表帖子.

Also it is not just Numpy giving me this issue- OpenCV is giving me the exact same errors. Will make separate post for that if needed.

推荐答案

已在Android版Python(p4a)项目解决问题的公关.我没有测试它,但是不同的人说它有用.

This issue is reported in Python for Android (p4a) project here, didn't knew it's actual for stable p4a. Nevertheless, by link you can find PR that fixes issue. I didn't test it, but different people say it works.

您可以尝试使用此修复程序构建numpy,这是您需要的:

You can try to build numpy with this fix, here's what you'll need:

  1. 请确保使用以下命令清除当前构建过程中剩下的所有内容:

  1. Make sure you clean all left from current building process with command:

buildozer distclean

使用命令使用修复程序克隆p4a分支:

Clone p4a branch with fix using command:

git clone -b p4a_numpy_fix https://github.com/mahomahomaho/python-for-android fix-numpy

更改您的buildozer.spec以使用此克隆的p4a版本(使用您的实际路径):

Change your buildozer.spec to use this cloned version of p4a (use your actual path):

p4a.source_dir = /home/ubuntu/p4a_numpy_fix

然后再次运行构建apk.如果一切正常,您将可以构建apk.如果不是这样,您将面临其他错误,这里不做任何保证:(

And run building apk again. If everything will work fine, you'll be able to build apk. If not you'll face another errors, no guarantees here :(

这篇关于Buildozer Numpy RuntimeError:断开的工具链:无法链接简单的C程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆