编译Python3的时候报一个错
在安装python的时候报了以下几个错,查了以下缺少安装包
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named ‘_ctypes’
#创建两个约定俗称的文件夹,来进行我们的软件包的存放和软件的安装
所有软件的安装路径
mkdir -p /usr/local/python3
所有软件压缩包的存放路径
mkdir -p /opt/software
#安装依赖环境
yum -y install gcc zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
#先安装依赖 ,针对此问题需要安装依赖,需要一个新的包libffi-devel,安装此包之后再次进行编译安装即可。
sudo yum install libffi-devel -y
make install
#我这边没有提前配置基本环境会报一个错
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'
#上传Python到software目录,并解压
root@node02 ~# tar -zxvf Python-3.7.3.tgz -C ../servers/
#切换到Python安装目录,编译安装目录
cd Python-3.7.3/
mkdir -p /usr/local/python3
./configure --prefix=/usr/local/python3
make && make install
编译报错、查看上面安装依赖,重新开始
#建立Python3的软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
#将/usr/local/python3/bin加入PATH
vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/usr/local/python3/bin
:wq
source ~/.bash_profile
#创建pip3的软链
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
#检查Python3及pip3是否可用
python3 --version
pip3 --version
[root@node01 Python-3.7.3]# python3 --version
Python 3.7.3
[root@node01 Python-3.7.3]# pip3 --version
pip 19.0.3 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)