pyenv和virtualenv的安装和使用

安装pyenv之前,首先要安装以下包:

$ sudo apt-get install git gcc make openssl libssl-dev libbz2-dev libreadline-dev libsqlite3-dev

安装pyenv:

Github way (recommended)

Install:

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

Update:

$ pyenv update

Uninstall:

pyenv is installed within $PYENV_ROOT (default: ~/.pyenv). To uninstall, just remove it:

$ rm -fr ~/.pyenv

以下是常用命令:

查看可供安装的包:

pyenv install --list

安装相应版本:

$ sudo pyenv install -v 3.4.2

安装完成后,更新数据库:

$ pyenv rehash

查看当前版本:

$ pyenv versions
* system (set by /usr/local/pyenv/version)
  3.4.2

设置python版本:

sudo pyenv global 3.4.2

 

virtualenv安装和使用:

#安装virtualenv

$ pip install virtualenv

#创建虚拟环境

$ virtualenv -p /usr/local/bin/python3.4 ENV3.4
Running virtualenv with interpreter /usr/local/bin/python3.4
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.4'
New python executable in ENV3.4/bin/python3.4
Also creating executable in ENV3.4/bin/python
Installing setuptools, pip...done.

或者

$ virtualenv --no-site-packages venv

#激活虚拟环境

$ source /ENV3.4/bin/activate

#查看当前环境下的安装包

$ pip list
pip (1.5.6)
setuptools (3.6)

#离开虚拟环境

$ deactivate

 

posted on 2015-12-03 09:31  中二向箔  阅读(557)  评论(0编辑  收藏  举报

导航