该平台缺少功能性 sem_open 实现,因此,需要所需的同步原语

This platform lacks a functioning sem_open implementation, thefore, the required synchronization primitives needed

我使用 Termux 在 Android phone 上安装了 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. 这是 link 对问题和问答线程的完整解释 https://github.com/termux/termux-app/issues/1272