安装 Python 时,直接报错,原因为环境缺少 libffi-devel 包

报错现象

找不到 _ctypes 模块

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'

处理方案

直接补 libffi-devel 包
RHEL/Fedora

yum install libffi-devel
# 或者
sudo dnf install libffi-devel

Debian/Ubuntu

sudo apt-get install libffi-dev

End…