我正在使用 Ubuntu 并安装了 Python 2.7.5 和 3.4.0。在 Python 2.7.5 中,我能够成功分配一个变量 x = Value('i', 2)
,但在 3.4.0 中没有。我正进入(状态:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/multiprocessing/context.py", line 132, in Value
from .sharedctypes import Value
File "/usr/local/lib/python3.4/multiprocessing/sharedctypes.py", line 10, in <
module>
import ctypes
File "/usr/local/lib/python3.4/ctypes/__init__.py", line 7, in <module>
from _ctypes import Union, Structure, Array
ImportError: No module named '_ctypes'
我刚刚通过安装3.4.0的源更新到3.3.2。它安装在 /usr/local/lib/python3.4 中。
我是否正确更新到 Python 3.4?
一件事我注意到 Python 3.4 安装在 usr/local/lib 中,而 Python 3.3.2 仍然安装在 usr/lib 中,所以它没有被覆盖。
原文由 htc_m8 发布,翻译遵循 CC BY-SA 4.0 许可协议
安装
libffi-dev
并重新安装 python3.7 为我解决了这个问题。干净地构建 py 3.7
libffi-dev
是必需的,否则以后的东西会失败如果使用 RHEL/Fedora:
要么
如果使用 Debian/Ubuntu: