[color=blue][b]1. 在MAC OS上安装Python v3.6:[/b][/color]
Mac OS X系统在版本10.8后会预安装Python v2.7,查看当前预安装版本命令:python -V
这个版本不建议删除,详见官方文档:[url]https://docs.python.org/3/using/mac.html[/url]
[quote]The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.[/quote]
安装包官方下载:[url]https://www.python.org/downloads/mac-osx/[/url]
用安装包安装或是用brew工具都可以~
顺便,下载版本比如Python 3.6.0rc1,其中的rc=Release Candidate,含义是"发布候选版",它不是最终的版本,而是最终版(RTM=Release To Manufacture)之前的最后一个版本。(摘自百度)
安装好v3.6后,对于Mac中多版本的python,使用不同的命令,如下:
[color=blue][b]2. 安装IDE[/b][/color]
很多IDE可供选择,stack overflow上有总结,戳: [url]http://stackoverflow.com/questions/81584/what-ide-to-use-for-python[/url]
由图看出不同的IDE的功能介绍:
[img]http://dl.iteye.com/upload/picture/pic/136990/3cec2e40-1137-3ec8-9031-9626cdc7343a.jpg[/img]
我选择的是eclipse的Pydev,官网: [url]http://www.pydev.org[/url],下载介绍: [url]http://www.pydev.org/download.html[/url]
插件和Eclipse是有版本匹配的,比如:
Eclipse 4.5, Java 8: PyDev 5.2.0
Eclipse 3.8, Java 7: PyDev 4.5.5
Eclipse 3.x, Java 6: PyDev 2.8.2
最新版本的eclipse 插件site地址是: [url]http://www.pydev.org/updates[/url]
其它版本查找: [url]http://www.pydev.org/update_sites/[/url]
我用的是经典版本Luna(4.4.2),所以准备安装5.1版本。
具体步骤: [b]Eclipse - Help - Install New Software - [add][/b]
Name: (自己输一个)比如: pydev - 5.1.2
Site: (按需选版本)http://www.pydev.org/update_sites/5.1.2
如果遇到错误:
[color=red]An error occurred while collecting items to be installed
session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).[/color]
解决方法: 修改eclipse.ini的jdk版本,我的默认JDK是1.8,而我的eclipse版本过低(通过添加-vm参数)。
安装好后重启eclipse,菜单Preferences下会多一项PyDev。
最后一项,配置Python interpreter:
Preferences - PyDev - Interpreters - Python Interpreter,点击:Advanced Auto-Config选出想要的版本。
若需要自己add,官方上的文档讲的非常详细,具体戳: [url]http://www.pydev.org/manual_101_interpreter.html[/url]
[color=blue][b]3. 写个Hello world验证下吧[/b][/color]
为了方便,添加新的视图,window - Open Perspective - PyDev
新建Python Project:
输出: hello world!
完毕!
Mac OS X系统在版本10.8后会预安装Python v2.7,查看当前预安装版本命令:python -V
这个版本不建议删除,详见官方文档:[url]https://docs.python.org/3/using/mac.html[/url]
[quote]The Apple-provided build of Python is installed in /System/Library/Frameworks/Python.framework and /usr/bin/python, respectively. You should never modify or delete these, as they are Apple-controlled and are used by Apple- or third-party software. Remember that if you choose to install a newer Python version from python.org, you will have two different but functional Python installations on your computer, so it will be important that your paths and usages are consistent with what you want to do.[/quote]
安装包官方下载:[url]https://www.python.org/downloads/mac-osx/[/url]
用安装包安装或是用brew工具都可以~
顺便,下载版本比如Python 3.6.0rc1,其中的rc=Release Candidate,含义是"发布候选版",它不是最终的版本,而是最终版(RTM=Release To Manufacture)之前的最后一个版本。(摘自百度)
安装好v3.6后,对于Mac中多版本的python,使用不同的命令,如下:
>python -V
Python 2.7.5
>python3 -V
Python 3.6.0
[color=blue][b]2. 安装IDE[/b][/color]
很多IDE可供选择,stack overflow上有总结,戳: [url]http://stackoverflow.com/questions/81584/what-ide-to-use-for-python[/url]
由图看出不同的IDE的功能介绍:
[img]http://dl.iteye.com/upload/picture/pic/136990/3cec2e40-1137-3ec8-9031-9626cdc7343a.jpg[/img]
我选择的是eclipse的Pydev,官网: [url]http://www.pydev.org[/url],下载介绍: [url]http://www.pydev.org/download.html[/url]
插件和Eclipse是有版本匹配的,比如:
Eclipse 4.5, Java 8: PyDev 5.2.0
Eclipse 3.8, Java 7: PyDev 4.5.5
Eclipse 3.x, Java 6: PyDev 2.8.2
最新版本的eclipse 插件site地址是: [url]http://www.pydev.org/updates[/url]
其它版本查找: [url]http://www.pydev.org/update_sites/[/url]
我用的是经典版本Luna(4.4.2),所以准备安装5.1版本。
具体步骤: [b]Eclipse - Help - Install New Software - [add][/b]
Name: (自己输一个)比如: pydev - 5.1.2
Site: (按需选版本)http://www.pydev.org/update_sites/5.1.2
如果遇到错误:
[color=red]An error occurred while collecting items to be installed
session context was:(profile=epp.package.jee, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).[/color]
解决方法: 修改eclipse.ini的jdk版本,我的默认JDK是1.8,而我的eclipse版本过低(通过添加-vm参数)。
-vm
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/bin/../jre/lib/server/libjvm.dylib
安装好后重启eclipse,菜单Preferences下会多一项PyDev。
最后一项,配置Python interpreter:
Preferences - PyDev - Interpreters - Python Interpreter,点击:Advanced Auto-Config选出想要的版本。
若需要自己add,官方上的文档讲的非常详细,具体戳: [url]http://www.pydev.org/manual_101_interpreter.html[/url]
[color=blue][b]3. 写个Hello world验证下吧[/b][/color]
为了方便,添加新的视图,window - Open Perspective - PyDev
新建Python Project:
if __name__ == '__main__':
print('hello world!');
输出: hello world!
完毕!