Python开发环境之pyenv环境搭建

1.安装环境需要的组件

yum install wget git patch gcc openssl-devel bzip2-devel readline-devel sqlite-devel

wget 下载pyenv安装脚本用;
git pyenv安装过程中需要从githup下载资源;
gcc path等 当我们安装好pyenv后我们使用pyenv安装python环境,事实上也是一个自动编译安装过程,所以编译工具gcc是必须的其他几个是python扩展需要依赖的组件。

2.下载安装pyenv

wget https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer
chmod +x pyenv-installer
./pyenv-installer

以上三行可以变为1行执行

curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

3.配置pyenv
安装完成后将pyenv加入环境变量
vi ~/.bash_profile

删除行 export PATH
替换为

export PATH="/root/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

使其生效需要重新加载配置文件

. ~/.bash_profile

或者登出再重新登录

4.验证
执行pyenv命令

[root@localhost ~]# pyenv 
pyenv 1.0.2
Usage: pyenv <command> [<args>]

Some useful pyenv commands are:
   commands    List all available pyenv commands
   local       Set or show the local application-specific Python version
   global      Set or show the global Python version
   shell       Set or show the shell-specific Python version
   install     Install a Python version using python-build
   uninstall   Uninstall a specific Python version
   rehash      Rehash pyenv shims (run this after installing executables)
   version     Show the current Python version and its origin
   versions    List all Python versions available to pyenv
   which       Display the full path to an executable
   whence      List all Python versions that contain the given executable

See `pyenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/yyuu/pyenv#readme

5.安装python环境
pyenv install 版本号
就可以了
例如
pyenv install 3.4.2

共有 0 条评论

Top