zoukankan      html  css  js  c++  java
  • python 基础1.1--windows/linux 下安装python

    一.windows下安装python
    1》windows上python后缀是.msi的,下载下来后,直接双击运行。会在c盘生成python.exe的文件,把python.exe的文件加入到windows环境变量中:我的电脑---属性---高级---环境变量--编辑--添加“c:python27”--确定   C:Python27   C:Python27Scripts
    下载地址:https://www.python.org/ftp/python/2.7.13/python-2.7.13.msi
    2》在windows下安装完python后,进入cmd,输入python,也会进入python命令行
    3》windows验证python及退出
     
     
    4》windows 退出python exit()
     
     
    二.linux 下安装python
    1》yum源安装
    安装pip命令,用pip安装ipython(pip  install  python)
    [root@localhost ~]# cd soft/
    [root@localhost soft]# ls
    epel-release-6-8.noarch.rpm
    [root@localhost soft]# rpm -ivh epel-release-6-8.noarch.rpm
    warning: epel-release-6-8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
    Preparing...                ########################################### [100%]
       1:epel-release           ########################################### [100%]
    [root@localhost soft]# cd /etc/yum.repos.d/
    [root@localhost yum.repos.d]# ls   //yum目录下生成epel   epel-testing.repo
    a  bak  CentOS-Base.repo  epel.repo  epel-testing.repo
    [root@localhost yum.repos.d]# yum -y install python-pip
    [root@localhost yum.repos.d]# pip install ipython   //安装ipython,会通过ipython的官网,下载当前最新的版本进行安装,注意,linux中python的版本是2.6,当前最新的iptyon的版本是6.0,网站上说明使用于python3,所以,安装后报错
    [root@localhost yum.repos.d]# pip install ipython==1.2.1  //指定ipython的版本进行安装,
    。。。。。。
    Installing collected packages: ipython
      Running setup.py install for ipython
    Successfully installed ipython-1.2.1
    。。。。。。。。。。
    [root@localhost yum.repos.d]# pip list   //查看
    You are using pip version 7.1.0, however version 9.0.1 is available.
    You should consider upgrading via the 'pip install --upgrade pip' command.
    distribute (0.6.10)
    iniparse (0.3.1)
    ipython (1.2.1)
    pip (7.1.0)
    pycurl (7.19.0)
    Pygments (2.2.0)
    pygpgme (0.1)
    pyxdg (0.18)
    setuptools (0.6rc11)
    six (1.10.0)
    urlgrabber (3.9.1)
    yum-metadata-parser (1.1.2)
    [root@localhost yum.repos.d]# ipython   //输入ipython命令就会进入python下,具有补全功能
    Python 2.6.6 (r266:84292, Nov 22 2013, 12:16:22)
    Type "copyright", "credits" or "license" for more information.
     
    IPython 1.2.1 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.
     
    In [1]:
     
     
      2》源码安装ipython
    [root@www soft]# ls
    51CTO下载-ipython-1.2.1.tar.gz
    [root@www soft]# tar xf 51CTO下载-ipython-1.2.1.tar.gz
    [root@www soft]# ls
    51CTO下载-ipython-1.2.1.tar.gz         redis-3.2.8.tar.gz
    ipython-1.2.1                          zabbix-2.0.12.tar.gz
    mongodb-linux-x86_64-rhel62-3.2.7.tgz
    [root@www soft]# cd ipython-1.2.1/
    [root@www ipython-1.2.1]# ls
    COPYING.txt  examples  PKG-INFO    scripts       setupegg.py  setup.py
    docs         IPython   README.rst  setupbase.py  setupext
    [root@www ipython-1.2.1]# python setup.py install   //python执行setup脚本,就可以用ipython补全了
     
     
    三.配置不同操作系统的环境变量
    1》配置windows 系统环境变量
    win10 操作系统环境变量在一下路径进行添加可执行程序:
    我的电脑---属性---高级---环境变量--编辑--添加
     
    2》linux系统环境变量配置
    例如要添加php命令,php安装在 /usr/local/webserver/php 下。永久有效添加php命令:
    [root@localhost ~]# vim /etc/profile   //在文件末尾添加如下两行内容
    .........................
    ........................
    #php
    export PATH=/usr/local/webserver/php/bin:$PATH
     
    [root@localhost ~]# source /etc/profile   //是环境变量生效
     
     
    四.python 从 "hello world"开始
    #/usr/bin/python
    #coding=utf-8
    #@Time   :2017/10/16 8:59
    #@Auther :liuzhenchuan
    #@File   :python 从 hello world 开始.py
     
    a = 'hell world'
    print a
    print '###'*20
     
    name = raw_input('please input you name: ')
    print 'hell world %s' % name
    >>> hell world
        ###############################################
        please input you name: liuzhenchuan
        hell world liuzhenchuan
     
     
     
  • 相关阅读:
    Id vs Instancetype
    【转】为什么要走出你的心理“舒适区”
    【转】深入浅出 iOS 之生命周期
    【转】Objective-C类初始化:load与initialize
    【转】Cocoapod 的安装和使用
    非对称加密回顾
    iOS中 Proxy和的delegate区别
    IOS 对JSON解析的要求
    内存对齐规则
    KVO 的进一步理解
  • 原文地址:https://www.cnblogs.com/lzcys8868/p/7675472.html
Copyright © 2011-2022 走看看