webtet 发表于 2018-5-22 06:53:49

python linux 安装

  参考文件地址
  http://ericslau.iteye.com/blog/1845654
  下载安装包
   可利用linux自带下载工具wget下载,如下所示:
    1 # wget http://www.python.org/ftp/python/3.3.0/Python-3.3.0.tgz
   2   tar -xzvf Python-3.3.0.tgz)
进入压缩目录后在执行以下命令
1 cd Python-3.3.0
    在编译前先在/usr/local建一个文件夹python3(作为python的安装路径,以免覆盖老的版本)
1 mkdir /usr/local/python3 ,一定要进入解压后得目录,里面才会有configure 该文件

开始编译安装
1 ./configure --prefix=/usr/local/python3执行该命令后创建makefile文件
  
  2 make
   3 make install
  注意
在执行./configure --prefix=/usr/local/python3 ,时出现

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... linux
checking for --without-gcc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/Python/Python-3.3.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
执行yum -y install gcc 后在安装执行上述命令即可
  
   此时没有覆盖老版本,再将原来/usr/bin/python链接改为别的名字
1 mv /usr/bin/python /usr/bin/python_old

  再建立新版本python的链接
1 ln -s /usr/local/python3/bin/python3 /usr/bin/python
  

  这个时候输入
1 python

  就会显示出python的新版本信息
1 Python 3.1.2 (r312:79147, Oct 21 2012, 01:03:21))
2 on linux2
3 Type "help", "copyright", "credits" or "license" for more information.
4 >>>

  PS:如果不建立新安装路径python3,而是直接默认安装,则安装后的新python应该会覆盖linux下自带的老版本,也有可能不覆盖,具体看安装过程了,这个大家可以自己试验下,当然如果还想保留原来的版本,那么这种方法最好不过了。
页: [1]
查看完整版本: python linux 安装