Mac打造python2 python3开发环境
2016-12-10 23:28
411 查看
最新版的MacOS Sierra默认带的python环境仍然为2.7.10,本文将介绍使用Brew安装python3.5并做简单的配置,打造python2,python3共存的开发环境
DONE
直接尝试brew安装,提示需要执行brew link gdbm
thatsitdeMacBook-Pro:~ thatsit$ brew install python3 Updating Homebrew... Error: You must `brew link gdbm` before python3 can be installed thatsitdeMacBook-Pro:~ thatsit$
按提示执行brew link gdbm,提示目录权限问题
thatsitdeMacBook-Pro:~ thatsit$ brew link gdbm Linking /usr/local/Cellar/gdbm/1.12... Error: Could not symlink share/man/man3/gdbm.3 /usr/local/share/man/man3 is not writable. thatsitdeMacBook-Pro:~ thatsit$
尝试sudo执行brew,提示已经不再支持以root权限执行
thatsitdeMacBook-Pro:~ thatsit$ sudo brew link gdbm Password: Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system. thatsitdeMacBook-Pro:~ thatsit$
确认目录权限并调整
thatsitdeMacBook-Pro:~ thatsit$ ll /usr/local/share/man/man3/ total 240 -rw-rw-r-- 1 root wheel 25111 1 12 2014 cdt.3 -rw-rw-r-- 1 root wheel 27894 1 12 2014 cgraph.3 -rw-rw-r-- 1 root wheel 1762 1 12 2014 expr.3 -rw-rw-r-- 1 root wheel 2103 1 12 2014 gvc.3 -rw-rw-r-- 1 root wheel 2966 1 12 2014 gvpr.3 -rw-rw-r-- 1 root wheel 9628 1 12 2014 pack.3 -rw-rw-r-- 1 root wheel 5386 1 12 2014 pathplan.3 -rw-rw-r-- 1 root wheel 15026 1 12 2014 tcldot.3tcl -rw-rw-r-- 1 root wheel 7109 1 12 2014 tkspline.3tk -rw-rw-r-- 1 root wheel 8157 1 12 2014 xdot.3 thatsitdeMacBook-Pro:~ thatsit$ thatsitdeMacBook-Pro:~ thatsit$ sudo chown -R thatsit /usr/local/share/man/man3/ thatsitdeMacBook-Pro:~ thatsit$
再次执行,OK
thatsitdeMacBook-Pro:~ thatsit$ brew link gdbm Linking /usr/local/Cellar/gdbm/1.12... 12 symlinks created thatsitdeMacBook-Pro:~ thatsit$ thatsitdeMacBook-Pro:~ thatsit$ brew install python3 ==> Installing dependencies for python3: xz ==> Installing python3 dependency: xz ==> Downloading https://homebrew.bintray.com/bottles/xz-5.2.2.el_capitan.bottle.tar.gz ######################################################################## 100.0% ==> Pouring xz-5.2.2.el_capitan.bottle.tar.gz Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink lib/pkgconfig/liblzma.pc /usr/local/lib/pkgconfig is not writable. You can try again using: brew link xz ==> Summary 🍺 /usr/local/Cellar/xz/5.2.2: 91 files, 1.4M ==> Installing python3 ==> Downloading https://homebrew.bintray.com/bottles/python3-3.5.2_3.el_capitan.bottle.tar.gz ######################################################################## 100.0%j ==> Pouring python3-3.5.2_3.el_capitan.bottle.tar.gz Error: The `brew link` step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink lib/pkgconfig/python-3.5.pc /usr/local/lib/pkgconfig is not writable. You can try again using: brew link python3 ==> Using the sandbox ==> /usr/local/Cellar/python3/3.5.2_3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.5.2_3/bin --install-lib=/usr/local/lib/python3.5/site-packages --single-version-externally-managed --record=installed.txt ==> /usr/local/Cellar/python3/3.5.2_3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.5.2_3/bin --install-lib=/usr/local/lib/python3.5/site-packages --single-version-externally-managed --record=installed.txt ==> /usr/local/Cellar/python3/3.5.2_3/bin/python3 -s setup.py --no-user-cfg install --force --verbose --install-scripts=/usr/local/Cellar/python3/3.5.2_3/bin --install-lib=/usr/local/lib/python3.5/site-packages --single-version-externally-managed --record=installed.txt ==> Caveats Pip, setuptools, and wheel have been installed. To update them pip3 install --upgrade pip setuptools wheel You can install Python packages with pip3 install <package> They will install into the site-package directory /usr/local/lib/python3.5/site-packages See: https://github.com/Homebrew/brew/blob/master/docs/Homebrew-and-Python.md .app bundles were installed. Run `brew linkapps python3` to symlink these to /Applications. ==> Summary 🍺 /usr/local/Cellar/python3/3.5.2_3: 3,498 files, 53.3M thatsitdeMacBook-Pro:~ thatsit$
添加python3环境变量
thatsitdeMacBook-Pro:~ thatsit$ tail -1 /etc/profile export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/python3/3.5.2_3/bin thatsitdeMacBook-Pro:~ thatsit$
测试
thatsitdeMacBook-Pro:bin thatsit$ python Python 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> ^D thatsitdeMacBook-Pro:bin thatsit$ python3 Python 3.5.2 (default, Oct 11 2016, 05:05:28) [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> thatsitdeMacBook-Pro:bin thatsit$
DONE
相关文章推荐
- 70.在Mac上打造方便好用的Python开发环境
- 在emacs中打造python开发环境
- Mac配置Python开发环境(Eclipse +Pydev+Python)
- Mac配置Python开发环境并实现简单的字符串和整数拼接
- [原]打造Python开发环境之Python环境
- Mac配置Python开发环境(Eclipse +Pydev+Python)
- Mac 上配置Python开发环境 Pydev + Eclipse
- Eclipse Kepler SR2 + Python 3.4 + JDK7+Pydev3.4 搭建 python 开发环境(MAC)
- Mac配置Python开发环境(Eclipse +Pydev+Python)
- 在mac OS X中配置python mysql开发环境
- [原]打造Python开发环境之初篇
- Mac OS X 搭建Python开发环境
- python --桌面开发pyqt安装(mac 环境)
- 在sublimetext上打造一个兼容virtualenv的web&python开发环境
- mac 安装python和Django开发环境
- 将mac打造成和linux差不多的c语言开发环境,完全新手版
- mac 安装python和Django开发环境
- 在 Mac OS X 下打造赏心悦目的开发环境
- Mac下python开发环境的相关配置
- 翻译:打造基于Sublime Text 3的全能python开发环境