问题描述
我正在构建可在Windows和python上运行的应用程序.它可以正确构建,并且此问题看起来应该已经在chaquopy的7.0.3中修复了;但是它对我不起作用.我已经包括尝试在android vm上运行的logcat.任何帮助将非常感激.如果需要,我可以包括更多错误消息或logcat的更多输出.
I am building an application that works on windows and in python. It builds correctly and this issue looks like it should have been fixed in 7.0.3 of chaquopy; however it does not work for me. I have included the logcat from the attempt to run on the android vm. Any help would be really appreciated. I can include more error messages or more output from the logcat if needed.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = "1.4.21"
repositories {
google()
jcenter()
maven { url "https://chaquo.com/maven" }
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.chaquo.python:gradle:9.1.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
当我在android上运行它时,它失败了.这是通过android studio打印出来的:
When I run this on android it fails. here is the print out via android studio:
2021-01-05 17:56:53.977 12952-12952/io.emerge.tactileengine E/AndroidRuntime: FATAL EXCEPTION: main
Process: io.emerge.tactileengine, PID: 12952
java.lang.RuntimeException: Unable to start activity ComponentInfo{io.emerge.tactileengine/io.emerge.tactileengine.MainActivity}: com.chaquo.python.PyException: ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: com.chaquo.python.PyException: ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.
at <python>.multiprocessing.synchronize.<module>(synchronize.py:30)
at <python>.zipimport.load_module(<frozen zipimport>:259)
at <python>.java.chaquopy.import_override(import.pxi:60)
at <python>.multiprocessing.queues.__init__(queues.py:39)
at <python>.multiprocessing.context.Queue(context.py:103)
at <python>.top.tactile_engine.setup_unity_comm(tactile_engine.py:67)
at <python>.top.tactile_engine.run(tactile_engine.py:54)
at <python>.asyncio.base_events.run_until_complete(base_events.py:612)
at <python>.asyncio.runners.run(runners.py:43)
at <python>.top.tactile_engine.main(tactile_engine.py:148)
at <python>.chaquopy_java.call(chaquopy_java.pyx:281)
at <python>.chaquopy_java.Java_com_chaquo_python_PyObject_callAttrThrows(chaquopy_java.pyx:253)
at com.chaquo.python.PyObject.callAttrThrows(Native Method)
at com.chaquo.python.PyObject.callAttr(PyObject.java:209)
at io.emerge.tactileengine.MainActivity.onCreate(MainActivity.kt:33)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.an
droid.internal.os.ZygoteInit.main(ZygoteInit.java:807)
推荐答案
Chaquopy 7.0.3和8.0.1中的修复用于导入 multiprocessing
模块而不实际使用其多进程的代码.特征.但是,您的代码似乎正在尝试创建一个多进程队列,该队列当前不起作用,因为Android不支持POSIX信号量.
The fixes in Chaquopy 7.0.3 and 8.0.1 were for code which imported the multiprocessing
module without actually using its multi-process features. However, it looks like your code is trying to create a multi-process queue, which doesn't currently work because Android doesn't support POSIX semaphores.
假设您的应用只有一个过程,最简单的解决方案是编辑代码以使用 multiprocessing.dummy
而不是 multiprocessing
.或者,您可以使用单进程 队列
直接使用API.
Assuming your app has only one process, the simplest solution is edit your code to use multiprocessing.dummy
instead of multiprocessing
. Or you could use the single-process queue
API directly.
这篇关于com.chaquo.python.PyException:ImportError:该平台缺少具有多重处理功能的sem_open的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!