Fork me on GitHub

Mac安装Python3.12开发环境

官网

https://www.python.org/downloads/

安装python

image
python-3.12.1-macos11.pkg下载后,安装一直下一步即可
验证是否安装成功,执行python3命令和pip3命令
image

配置环境变量

获取python3安装位置并配置在.bash_profile

#查看python路径
which python3

#修改配置文件.bash_profile
open -e .bash_profile    #文件存在,用文本工具打开,需要保存
vi ~/.bash_profile    #文件不存在

#在~/.bash_profile中添加如下代码,python3起别名python
alias python="/Library/Frameworks/Python.framework/Versions/3.12/bin/python3"

#使配置文件生效
source ~/.bash_profile

image

VSCode安装python插件

image
command shift P,输入Python:Select Interpreter配置python解释器
image
选择刚才安装的python3.12
image

posted @ 2024-01-05 11:04  秋夜雨巷  阅读(3462)  评论(0)    收藏  举报