该平台缺乏有效的 sem_open 实现,因此,需要所需的同步原语

Наг*_*мер 4 python termux

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

from multiprocessing import synchronize 
Run Code Online (Sandbox Code Playgroud)

这是回溯

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.
Run Code Online (Sandbox Code Playgroud)

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

小智 5

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

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