yum install zlib-devel bzip2-devel openssl-devel ncurese-devel uuid libffi libffi-devel
yum install tcl tcl-devel tk tk-devel
./configure --prefix=/usr/local/python3 --enable-shared CFLAGS=-fPIC
make && make install
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
如果在编译中出现如下错误
In file included from /home/888/Downloads/Python-3.7.2/Modules/_uuidmodule.c:8:0:
/usr/include/uuid.h:94:24: error: conflicting types for ‘uuid_t’
typedef struct uuid_st uuid_t;
^
In file included from /home/888/Downloads/Python-3.7.2/Modules/_uuidmodule.c:5:0:
/usr/include/uuid/uuid.h:44:23: note: previous declaration of ‘uuid_t’ was here
typedef unsigned char uuid_t[16];
^
In file included from /home/888/Downloads/Python-3.7.2/Modules/_uuidmodule.c:8:0:
/usr/include/uuid.h:107:22: error: conflicting types for ‘uuid_compare’
extern uuid_rc_t uuid_compare (const uuid_t *_uuid, const uuid_t *_uuid2, int *_result);
参考文章: https://my.oschina.net/mengyoufengyu/blog/2249877
这里把解决方案直接贴出来
即修改如下文件 ./Modules/_uuidmodule.c
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifdef HAVE_UUID_UUID_H
#include
#endif
#ifdef HAVE_UUID_H
#include
#endif
//修改为
#define PY_SSIZE_T_CLEAN
#include "Python.h"
#ifdef HAVE_UUID_UUID_H
#include
// #endif
// #ifdef HAVE_UUID_H
#else
#include
#endif