CentOS python environment configuration method

高洛峰
Release: 2017-03-09 09:30:50
Original
1982 people have browsed it

CentOS python environment configuration

@(Study notes)

Use pyenv to manage python version

  • ##pyenv tool configuration:

    $ git clone https://github.com/yyuu/pyenv.git ~/.pyenv
    
    $ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
    $ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
    
    $ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
    
    $ exec $SHELL
    Copy after login

  • Common pyenv commands:

    $ pyenv install 2.7.6 // 安装python 2.7.6版本
    $ pyenv local 2.7.6   // 这个应用使用2.7.6版本
    $ pyenv global 2.7.6  // 全局环境版本
    
    $ pyenv versions // 列出已经安装的所有版本,*表示当前环境正在使用的版本
          2.5.6
          2.6.8
         *2.7.6 (set by /home/yyuu/.pyenv/version)
          3.3.3
          jython-2.5.3
          pypy-2.2.1
    Copy after login

Use pip to manage python package versions

  1. pip installation:

    # 首先安装epel扩展源:
    $ sudo yum -y install epel-release
    
    # 然后安装python-pip
    $ sudo yum -y install python-pip
    
    # 清理cache
    $ sudo yum clean all
    Copy after login

  2. Pip common commands:

  3. # 安装1.9版本的django
    pip install django==1.9
    
    # 卸载包
    $ pip uninstall <包名> 或 pip uninstall -r requirements.txt
    
    # 更新包
    $ pip install -U <包名>
    
    # 更新pip
    $ pip install -U pip
    
    # 显示包所在的目录
    $ pip show -f <包名>
    
    # 搜索包
    $ pip search <搜索关键字>
    
    # 查询可升级的包
    $ pip list -o
    
    # 国内pypi镜像
    # 豆瓣:https://pypi.douban.com/simple
    # 中国科学技术大学:https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/
    # 清华大学TUNA:https://pypi.tuna.tsinghua.edu.cn/simple
    Copy after login



    The above is the detailed content of CentOS python environment configuration method. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!