ModuleNotFoundError: No module named ‘_ctypes‘ ERROR: Command errored out with exit status 1: python

问题描述

Ubuntu系统下通过pip安装包时,出现ModuleNotFoundError: No module named ‘_ctypes’ ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output错误。

问题分析

这是因为缺少了外部函数库(libffi)的开发链接库软件包,所以在安装pip的时候就报了"ModuleNotFoundError: No module named ‘_ctypes’"的错误。有的人在安装python时就会出这种错,但我并没有,我是在安装psutil等包时出这种错误。

解决办法

1、第一步运行以下两个命令(非必须,只是我在解决过程中使用了这两个命令)

sudo apt-get update
sudo apt-get upgrade

2、通过以下命令下载libffi软件包(关键)

sudo apt-get install libffi-dev

3、执行ldconfig命令,加载新的libffi.so

ldconfig

4、重新编译出现问题的python,在命令行中先cd到python源文件目录下,以下为我的python源文件(关键)
ModuleNotFoundError: No module named ‘_ctypes‘ ERROR: Command errored out with exit status 1: python_第1张图片
5、通过以下命令重新编译python源文件(关键)

make
sudo make install

若以上方法不能解决你的问题,欢迎私聊!

你可能感兴趣的:(Python,安装篇,ubuntu,pip,python)