#cd Python-3.7.0b3
# ls
// aclocal.m4 configure.ac install-sh Mac Objects Programs setup.py
// config.guess Doc Lib Makefile.pre.in Parser pyconfig.h.in Tools
// config.sub Grammar LICENSE Misc PC Python
// configure Include m4 Modules PCbuild README.rst
//可以看到有可执行文件configure,没有makefie文件
//可以通过./configure --help查看该软件源代码configure的帮助信息
安装编译
#./configure --prefix=/usr/local/python3 //把python3安装到/usr/local/python3目录下
//执行./configure后可以ls,发现在当前目录下已经生成Makefile文件
#make -j 20 //可以省略Makefile,因为make会自动寻找该目录下的Makefile或makefile文件进行编译
#make install //安装python3
//发现报错:
// zipimport.ZipImportError: can't decompress data; zlib not available
// make: *** [install] Error 1
//原因是依赖性问题,下载zlibr软件包和zlib的devel包
#yum -y install zlib zlib-devel
#make install //重试
//发现又报错:
//ModuleNotFoundError: No module named '_ctypes'
//原因是3.7版本需要一个新的包libffi-devel
#yum install libffi-devel -y
#make install //重试
//successfully installed pip-9.0.3 setuptools-39.0.1 成功安装
安装完后的配置
bin文件:
#vim /etc/profile.d/python3.sh
PATH=$PATH:/usr/local/python3/bin
//重启,使修改生效
库文件:
#vim /etc/ld.so.conf.d/python.conf
/usr/local/python
#ldconfig -v //加载修改后的配置,并检查python3库文件是否被加载进去
头文件:
#ln -s /usr/local/python3/include /usr/include/python3 //为库文件做链接
帮助信息:
#vim /etc/man_db.conf
MANPATH_MAP /usr/local/python3/bin /usr/local/python3/share/man
//重启,使修改生效
检测:
#vim test.py
#!/usr/bin/env python3
print("test successful!")
#chmod +x test.py
#./test.py
>>>test successful!