该平台缺少功能正常的sem_open实现,这是所需的同步原语



我使用Termux在我的Android手机上安装了python 3.7.3。当我尝试从python shell中的多处理导入同步时,我收到上述错误。这是我的代码

from multiprocessing import synchronize 

这是回溯

Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.7/multiprocessing/synchronize.py", line 28, in <module>
from _multiprocessing import SemLock, sem_unlink
ImportError: cannot import name 'SemLock' from '_multiprocessing' (/data/data/com.termux/files/home/storage/predictions/env/lib/python3.7/lib-dynload/_multiprocessing.cpython-37m.so)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/data/data/com.termux/files/usr/lib/python3.7/multiprocessing/synchronize.py", line 32, in <module>
" synchronization primitives needed will not" +
ImportError: This platform lacks a functioning sem_open implementation, therefore, the required synchronization primitives needed will not function, see issue 3770.

之后,我试图看到提到 3770 问题,但似乎官方网站上的 url 不起作用。谁能帮我解决这个问题

除非您是错误消息本身所述的 Android 开发人员,否则此问题无法解决。

sem_open是用于初始化或打开现有 POSIX 信号灯的函数。信号量是在线程之间共享的变量,用相当粗略的术语来说,它是一个系统级组件。Android 发行版缺少此组件,因此,您无能为力。

我花了很多时间来解决这个问题,并决定在termux github页面上打开错误报告,并从termux开发人员那里获得答案Android supports multiprocessing, but not semaphores.这是问题和问答线程的完整解释的链接 https://github.com/termux/termux-app/issues/1272

最新更新