zoukankan      html  css  js  c++  java
  • Python Env


    简介:

    记录 CentOS 6.x Python 环境的安装步骤。

    一、安装依赖包

    shell > yum -y install epel-release
    shell > yum -y install gcc gcc-c++ wget readline-devel zlib-devel openssl-devel sqlite-devel
    
    shell > python -V
    Python 2.6.6

    一、安装 Python 2.7

    shell > cd /usr/local/src; wget -c https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
    shell > tar zxf Python-2.7.13.tgz
    sehll > cd Python-2.7.13
    shell > ./configure && make && make install
    
    shell > python2 -V
    Python 2.7.13

    二、安装 Python 3.5

    shell > cd /usr/local/src; wget -c https://www.python.org/ftp/python/3.5.4/Python-3.5.4.tgz
    shell > tar zxf Python-3.5.4.tgz
    shell > cd Python-3.5.4
    shell > ./configure && make && make install
    
    shell > python3 -V
    Python 3.5.4

    三、安装 Virtualenv

    shell > pip3 install virtualenv

    四、创建不同的 Python 环境

    1、Python 2.x

    shell > virtualenv --no-site-packages -p python2 py2.x
    shell > source py2.x/bin/activate
    
    (py2.x) shell > python -V
    Python 2.7.13
    
    (py2.x) shell > pip install ipython
    
    (py2.x) shell > ipython
    Python 2.7.13 (default, Aug 9 2017, 20:15:06) 
    Type "copyright", "credits" or "license" for more information.
    
    IPython 5.4.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]:
    
    (py2.x) shell > deactivate
    # 创建了一个 python2 的虚拟环境 名称为 py2.x,之后激活这个虚拟环境
    # 可以看到默认的 python 版本已经不是原来的 2.6.6
    # 使用 pip 安装 ipython 软件包
    # ipython 调用的 python 版本也是 2.7.13
    # 退出虚拟环境

    2、Python 3.x

    shell > virtualenv --no-site-packages -p python3 py3.x
    shell > source py3.x/bin/activate
    
    (py3.x) shell > python -V
    Python 3.5.4
    
    (py3.x) shell > pip install ipython
    
    (py3.x) shell > ipython
    Python 3.5.4 (default, Aug 9 2017, 21:57:01) 
    Type 'copyright', 'credits' or 'license' for more information
    IPython 6.1.0 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]:
    
    (py3.x) shell > deactivate

    # End

  • 相关阅读:
    redis数据结构
    XMAPP 的安装与配置
    Android 工具类 异常处理类CrashHandler
    Android Config通用类来记录信息
    Android AppUtil通用类
    Android 用Chrome浏览器打开url 自定义样式
    Diycode开源项目 如何解决InputMethodManager造成的内存泄漏问题
    Diycode开源项目 SitesListFragment分析
    Diycode开源项目 NodeListFragment分析
    Diycode开源项目 搭建可以具有下拉刷新和上拉加载的Fragment
  • 原文地址:https://www.cnblogs.com/wangxiaoqiangs/p/7325105.html
Copyright © 2011-2022 走看看