1.在官网上下载Python的Linux源码包
2.解压源码包,在下载文件夹中解压就可以了,安装的时候系统会自动安装到默认的应用目录
3.在解压后的文件夹中执行 ./configure 命令
最后会提示生成了 MakeFIle文件
补:
configure
命令执行完之后,会生成一个
Makefile
文件,这个
Makefile
主要是被下一步的
make
命令所使用。打开
Makefile
你就会发现,里边制定了构建的顺序,
Linux
需要按照
Makefile
所指定的顺序来构建
(build)
程序组件。
4.执行 make 命令,生成可执行文件
5.执行 make install 命令
make install
实际上是把生成的执行文件拷贝到
linux
系统中必要的目录下,比如拷贝到
/usr/local/bin
目录下,这样所有
user
就都能运行这个程序了。
以上2-5步骤,是安装源码包的一般步骤
cent os7上安装的时候遇到的问题:
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux2
checking EXTRAPLATDIR...
checking for --without-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/data/python/Python-2.7.8':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
查了一下,发现有一种可能是没有安装gcc编译器,查看了一下本机
gcc -v
果然没有安装gcc编译器,所以先执行
yum install gcc 安装一下再去执行安装python
以上2-5步骤,是安装源码包的一般步骤
cent os7上安装的时候遇到的问题:
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... 32-bit
checking MACHDEP... linux2
checking EXTRAPLATDIR...
checking for --without-gcc... no
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... configure: error: in `/data/python/Python-2.7.8':
configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details
查了一下,发现有一种可能是没有安装gcc编译器,查看了一下本机
gcc -v
果然没有安装gcc编译器,所以先执行
yum install gcc 安装一下再去执行安装python