python学习之pyenv环境搭建

发布时间:2019-07-02 13:39:03编辑:auto阅读(1281)

    1.安装git,github地址为https://github.com/pyenv/pyenv-installer/
     yum install git -y
    2.安装python编译依赖环境
     yum -y install gcc make patch gdbm-devel openssl-devel sqlite-devel     readline-devel zlib-devel bzip2-devel
    3.创建python用户用于搭建pyenv python多版本管理环境
     useradd python
     passwd python 
    4.安装pyenv环境
     curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
    5.在python用户的环境变量目录~/.bash_profile下添加环境变量
     export PATH
     export PATH="/home/python/.pyenv/bin:$PATH"
     eval "$(pyenv init -)"
     eval "$(pyenv virtualenv-init -)"
    6.python查看版本命令:python --version
       pyenv命令:
         pyenv install -l #列出所有能安装的包
         pyenv help
             local       #指定本地pyenv环境,其目录下所有子目录都会递归继承其属性
             global     #指定全局的环境
             shell       #指定当前会话
             install     #指定安装的版本
             uninstall #卸载指定的安装环境包
             rehash   
             version   #查看当前环境使用的pyenv版本
             versions #查看所有的存在的pyenv版本,带*号的为当前的pyenv环境版本
             which    
             whence   
    7.virtualenv虚拟环境设置
      [python@node1 python3.5.3]$ pyenv versions
       system
     * 3.5.3 (set by /home/python/python3.5.3/.python-version)
       3.6.2
    
     [python@node1 python3.5.3]$ pyenv virtualenv 3.5.3 3-5-3 #将3.5.3版本的python命名为3-5-3的别名
     Requirement already satisfied: setuptools in /home/python/.pyenv /versions/3.5.3/envs/3-5-3/lib/python3.5/site-packages
     Requirement already satisfied: pip in /home/python/.pyenv/versions/3.5.3/envs/3-5-3/lib/python3.5/site-packages
     [python@node1 python3.5.3]$ pyenv versions
      system
      3-5-3
    * 3.5.3 (set by /home/python/python3.5.3/.python-version)
      3.5.3/envs/3-5-3
      3.6.2
    
     [python@node1 python3.5.3]$ pyenv local 3-5-3 #使用虚拟环境时前面多出了一个名称
     (3-5-3) [python@node1 python3.5.3]$ pyenv version
     3-5-3 (set by /home/python/python3.5.3/.python-version)
     (3-5-3) [python@node1 python3.5.3]$ 
    
    8.安装ipython
        pip install ipython
    9.安装Jupyter,基于web的交互式笔记本
        pip install Jupyter
        jupyter notebook help
        jupyter notebook password  #更改密码
        jupyter notebook --ip=0.0.0.0 #定义所有IP都可以访问该网页http://IP:8888/
    10.最后就是使用环境测试一下第一个程序咯:  

    python学习之pyenv环境搭建

关键字

上一篇: Python学习-函数

下一篇: iptables(3)