【MAC】用自带的python3安装jupyter
首先是有一个误区
//直接使用下面的指令是不可以的
pip3 install jupyter
会出现这样的问题
虽然也是正常安装了,但是如果直接使用jupyter指令,是无法使用的。
按照下面的方法进行jupyter 的安装
- 查看已安装的python
which python3
- 安装jupyter
安装jupyter,可以安在系统,也可以安在使用者的个人资料夹,最好是安在后者也就是使用者的个人资料夹的位置。
python3 -m pip install jupyter --user
安装过程会出现这样的warning
WARNING: The scripts jupyter, jupyter-migrate and jupyter-troubleshoot are installed in '/Users/yangxinyu/Library/Python/3.9/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
这个的意思是「你所安装的jupyter没有放在预设路径($PATH)內,而是放在/Users/yangxinyu/Library/Python/3.9/bin」。举个例子,预设路径里面有python3,所以我们只需要在terminal輸入python3就可以执行,不需要打上完整的/usr/bin/python3。因为预设路径的緣故,所以执行Jupyter Notebook,要这样做:
/Users/yangxinyu/Library/Python/3.9/bin/jupyter notebook
- 这样会比较麻烦,所以我们还是设置一下
# For zsh user
echo export PATH="/Users/yangxinyu/Library/Python/3.9/bin:${PATH}" >> ~/.zshrc
source ~/.zshrc
# For bash user
echo export PATH="/Users/yangxinyu/Library/Python/3.9/bin:${PATH}" >> ~/.bashrc
source ~/.bashrc
- 确认预设路径是否成功
which jupyter
- 使用jupyter
jupyter notebook