$ brew install python --framework --universal
The –framework option tells it to build as a Framework, which has some downstream niceties, and –universal builds a universal (32/64 bit) version.
$ cd ~/projects
$ virtualenv --no-site-packages project_name
The --no-site-packages flag is deprecated; it is now the default behavior.
New python executable in project_name/bin/python
Installing setuptools............done.
Installing pip...............done.
11.启动虚拟环境
首先进入刚刚建立的虚拟环境目录,比如:
$ cd project_name
$ source bin/activate
注意,此时shell提示符前多了虚拟环境的名称提示:
(project_name)….$
Now,do anything you want.
转移到mac上了。这里是在lion中搭建python开发环境的简单记录。这份记录不是一份step by step.而是事后写的记录,可能有记忆遗漏。如果有错误,请指正。
1.安装homebrew的准备
3.配置环境变量:
加入以下内容:
Ok,这样homebrew就装好了。
4.brew的简单命令
5.安装python
6.将python加入path
7.检查安装是否正确
此时,最好重启term。如果要确认修改是否正确,可以用which python和which easy_install查看python的路径是否正确。如果返回为
/usr/local/bin/python 和
/usr/local/share/python/easy_install 那么,安装正确
8.通过easy_install安装pip
9.安装virtualenv 和 virtuanenvwarpper
10.建立和项目相关的env
比如,项目文件在~/projects中,那么,
11.启动虚拟环境
首先进入刚刚建立的虚拟环境目录,比如:
注意,此时shell提示符前多了虚拟环境的名称提示: (project_name)….$ Now,do anything you want.
12.退出虚拟环境
13.pip的设定
如果要保证在虚拟环境中调用系统的pip,可以在~/.bash_profile里加上:
如果要让系统的pip自动调用虚拟环境中的pip
14.安装你需要的软件包(注意提示符)
(project_name)....$ pip install pkg_name 【END】
ttp://matrix.windhunter.net/blog/2012/01/setup-python-env-on-lion-471.html