vi ~/.bash_profile
//增加路径(默认安装anaconda的时候已经被改写)
# added by Anaconda3 4.2.0 installer
export PATH="/Users/cathar/anaconda/bin:$PATH"
source ~/.bash_profile //个人亲测之后有效
jupyer-notebook //即可在网页看到目录中的所有文件,并且可以试运行.
在jupyter中运行python命令的时候,会发现python 2、3不兼容的情况。本来以为切换版本很简单的事,看了好多地方还是没有找到解决办法。tools倒是安装了一堆。下面说一些总结:
// anaconda-2.4.0 # 支持Python 2.6和2.7
// anaconda3-2.0.1 # 支持Python 3.3和3.4
//(1) 查看Mac系统自带python环境在:
$cd/System/Library/Frameworks/Python.framework/Versions/
$ls
2.3 2.5 2.6 2.7 Current
//(2)查看用户安装python默认安装在:
$cd /Library/Frameworks/ //我这里没有
//(3) 用户安装anaconda后,自带的python环境.
/Users/cathar/anaconda/bin
//查看当前使用python版本
$which python
/Users/cathar/anaconda/bin/python
参考:
https://ipython.readthedocs.io/en/latest/install/kernel_install.html
//通过命令 python2、python 安装不同的环境
$python2 -m ipykernel install --user
$python2 -m ipykernel install --user --name 2.7env --display-name "Python (2.7env)"
$python -m ipykernel install --user --name 3.5env --display-name "Python (3.5env)"
//使用conda查看所有环境信息(含jupyter页面的core版本)
cathardeMacBook-Pro:~ cathar$ conda info --envs
# conda environments:
#
2.7env /Users/cathar/anaconda/envs/2.7env
3.5env /Users/cathar/anaconda/envs/3.5env
root * /Users/cathar/anaconda //*代表为默认环境
$ python --version
Python 3.5.2 :: Anaconda 4.2.0 (x86_64)
$ cd /Users/cathar/Library/Jupyter/kernels/
cathardeMacBook-Pro:kernels cathar$ ls
2.7env 3.5env python2
//在命令行激活环境为不同的python版本
$ source activate 2.7env
(2.7env) cathardeMacBook-Pro:kernels cathar$ python
Python 2.7.12 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:43:17)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>>
(2.7env) cathardeMacBook-Pro:kernels cathar$ source activate 3.5env
(3.5env) cathardeMacBook-Pro:kernels cathar$ python
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 2 2016, 17:52:12)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
$ conda list
参考:http://conda.pydata.org/docs/using/envs.html#remove-an-environment