最近想学习flask,看到建议使用virtualenv,所以学习在linux平台安装
1、在root账户下执行
[root@home]# sudo easy_install virtualenv
Searching for virtualenv
Reading https://pypi.python.org/simple/virtualenv/
Best match: virtualenv 15.0.2
Downloading https://pypi.python.org/packages/5c/79/5dae7494b9f5ed061cff9a8ab8d6e1f02db352f3facf907d9eb614fb80e9/virtualenv-15.0.2.tar.gz#md5=0ed59863994daf1292827ffdbba80a63
Processing virtualenv-15.0.2.tar.gz
Writing /tmp/easy_install-cG0DOG/virtualenv-15.0.2/setup.cfg
Running virtualenv-15.0.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-cG0DOG/virtualenv-15.0.2/egg-dist-tmp-cxBl5i
warning: no previously-included files matching '*' found under directory 'docs/_templates'
warning: no previously-included files matching '*' found under directory 'docs/_build'
Adding virtualenv 15.0.2 to easy-install.pth file
Installing virtualenv script to /usr/bin
Installed /usr/lib/python2.7/site-packages/virtualenv-15.0.2-py2.7.egg
Processing dependencies for virtualenv
Finished processing dependencies for virtualenv
2、virtualenv安装完,可以立即打开shell,然后创建自己的环境。通常创建一个项目文件夹,并在其下创建一个env文件夹
[flask@home myproject]$ virtualenv --distribute venv
New python executable in /home/flask/myproject/venv/bin/python
Installing setuptools, pip, wheel...done.
[flask@home myproject]$ ls
venv
[flask@home myproject]$
3、只需要激活相应的环境,就可以在项目中工作,执行
[flask@home myproject]$ source venv/bin/activate
(venv) [flask@homemyproject]$
4、键入以下的命令来激活 virtualenv 中的 Flask:
[flask@home bin]$ pip install flask