目录
一、序言
最近想在自己的Mac上安装下Python玩一玩,搜了下网上资料要么过时了要么讲的比较乱,决定自己亲自安装测试一番,顺便mark下。
二、安装方法
安装python3
进入终端,使用Homebrew安装python3,命令如下:
# brew install python
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/services, homebrew/core and homebrew/cask).
...
...
Python has been installed as
/opt/homebrew/bin/python3
Homebrew一般会先自动更新自己,如果长时间没更新的话可能时间比较久,另外,如果是第一次安装python也可能因为网速慢会比较久,可自行百度利用代理安装python,最后自动安装最新的python3和pip3。
查看版本
注意:这里命令必须输入python3而不是python,输入python会报zsh: command not found: python错误,因为当前最新的版本就是python3。
# python3 -V
Python 3.9.6
# pip3 -V
pip 23.2.1 from /Users/panda/Library/Python/3.9/lib/python/site-packages/pip (python 3.9)
安装Jupyter Notebook
可以使用pip3安装jupyter notebook
# pip3 install notebook
查看Jupyter
panda@pan ~ % pip3 show notebook
Name: notebook
Version: 7.0.4
Summary: Jupyter Notebook - A web-based notebook environment for interactive computing
启动Jupyter
# python3 -m notebook
执行后会在本机8888端口启动一个Jupyter WebUI,可通过浏览器访问地址:http://127.0.0.1:8888。