Python手札

为者常成,行者常至

Thoughts, stories and ideas.


pyenv环境部署

pyenv是一款Python多版本管理工具,它可以很好的管理Python解释器、Python版本和Python虚拟环境,对于日常开发中,是一款很有必要安装的利器。

安装依赖包

[python@vultr data]$ yum -y install gcc git make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel 

安装pyenv

[python@vultr data]$ curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
...
remote: Counting objects: 10, done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 10 (delta 1), reused 5 (delta 0), pack-reused 0
Unpacking objects: 100% (10/10), done.

WARNING: seems you still have not added 'pyenv' to the load path.

# Load pyenv automatically by adding
# the following to ~/.bash_profile:

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

配置pyenv环境变量

[python@vultr data]$ vim ~/.bash_profile  //环境变量配置,追加到 ~/.bash_profile 文件中
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

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

[python@vultr data]$ source  ~/.bash_profile //source重载一下

pyenv安装python版本的时候下载的安装包在/home/python/.pyenv/cache
pyenv安装的python版本在/home/python/.pyenv/versions

更早的文章

Centos7安装Mysql数据库

自从Mysql数据库软件被sun公司收购后(后来sun又被Oracle收购),新东家一心一意的想着样把Mysql商业化(就是想卖钱),无奈之下Mysql的作者自己又写了一款开源数据库软件(和Mysql…

继续阅读