Liunx中python报错ModuleNotFoundError: No module named ‘_ctypes’
本人使用ubuntu敲pyspark报错ModuleNotFoundError: No module named ‘_ctypes’
原因:无‘_ctypes’包
解决步骤
一、安装libffi-dev
二、重新编译python
实现:
一、
sudo apt-get install libffi-dev
我Ubuntu,CentOS和其他的自己找命令把这个包安上。(原谅俺也小白)
二、
很重要的一步。如果你之前已经安了python,只执行上一步其实是解决不了问题的,你需要重新编译python!!!很多文章都没说这一步,浪费咱好长时间。
(如果之前已经能打开和使用python的基本功能,这一步并不需要到处更改python配置)
重新编译python的步骤如下:
1.找个你想要安装的版本的python压缩包,替代你之前python版本(和你已安装版本相同的压缩包也可以,我就是为了解决无_ctypes重安了一遍)。给个小例子
wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tar.xz
2.解压。
tar -xf Python-3.6.3.tar.xz
(或例如
tar -zxvf Python-3.7.1.tgz
等等等…
取决于你下的python安装包类型)
3.进入你原来的python的安装路径
cd Python-3.6.3/
4.重新编译!!(关键的一步)
./configure --enable-loadable-sqlite-extensions && make && sudo make install
完毕。
参考文章:
https://stackoverflow.com/questions/20126475/importerror-no-module-named-sqlite3-in-python3-3