Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.42 KB

2016-12-02-install-python.md

File metadata and controls

55 lines (40 loc) · 1.42 KB
layout title date
post
安装Python环境
2016-12-02 20:53

安装Python环境

{% highlight bash %}

sudo yum install -y python-pip

sudo pip install virtualenv

// 创建一个新工作环境 helloworld
// --no-site-packages 这个选项忽略全局安装的包
// 所有在此环境需要的包,都会独立安装到此环境下
virtualenv -p /usr/bin/python2.7 helloworld

// 激活helloworld环境
source helloworld/bin/activate
pip install requests

// 退出helloworld环境
deactivate 

// 导出当前工作环境配置列表
pip freeze > requirements.txt

// 重建工作环境
pip install -r requirements.txt

// virtualenvwrapper
// ref : http://virtualenvwrapper.readthedocs.org/en/latest/command_ref.html
pip install virtualenvwrapper
export WORKON_HOME=~/pyenv
source /usr/local/bin/virtualenvwrapper.sh
mkvirtualenv helloworld

// 使用国内pip源站
// http://mirrors.aliyun.com/pypi/simple
/etc/pip.conf
    [global]
    index-url = http://pypi.douban.com/simple

{% endhighlight %}

参考