ITPub博客

首页 > 应用开发 > IT综合 > Python之linux平台安装

Python之linux平台安装

原创 IT综合 作者:kaixinguo8115 时间:2014-06-23 02:36:43 0 删除 编辑
一、简介
      本文主要介绍在linux 环境下安装Python环境。
二、安装过程
     1.下载地址
        https://www.python.org/download#pubkeys
        我使用的版本是Python-2.7.7。
     2.安装过程
        2.1解压文件
            shell>tar -zxf Python-2.7.7.tgz
            shell>cd Python-2.7.7
            shell>./configure
            shell>make
            shell>make install
    3.环境测试
       3.1命令测试
           在shell环境下直接执行python命令,会进入python环境。如下:
           shell>python
           Python 2.7.7 (default, Jun 22 2014, 21:44:27)
           [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
           Type "help", "copyright", "credits" or "license" for more information.
           >>> exit();
           shell>python
           Python 2.7.7 (default, Jun 22 2014, 21:44:27)
           [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
           Type "help", "copyright", "credits" or "license" for more information.
           >>>quit();
           shell>
           可见,在shell环境下执行python命令,可以进入python环境;执行exit()或者quit()命令,会退出python环境。
      3.2脚本测试
         测试脚本内容:python_test.py
         #!/usr/bin/env python
          #coding=utf-8
          #---- 测试 ----
          print 'hello,world';
          注意:要以脚本执行python脚本,需要声明环境为python。声明方法:#!/usr/bin/env python。如果要使用中文,需要在脚本中,声明---“#coding=utf-8”。否则,在执行脚本时,会报错:“SyntaxError: Non-ASCII character '\xe6' in file......”
      安装测试完毕!

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26418713/viewspace-1191406/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-01-30

  • 博文量
    13
  • 访问量
    86092