Macos下修改Python版本

MacOS下修改Python版本

安装

查看本机已安装的Python版本:where python3

bash 复制代码
~ where python3
/usr/bin/python3
/usr/local/bin/python3
/Library/Frameworks/Python.framework/Versions/3.12/bin/python3

如果没有你想要的版本,去python官网下载安装包。

配置环境

防止踩坑:一般情况下大家的MacOS使用的是zsh ,所以不要去修改 base_profile

直接在~/.zshrc 配置文件添加如下内容:

1.编辑配置文件:vim ~/.zshrc

bash 复制代码
#python env conf
export PYTHON_HOME=/Library/Frameworks/Python.framework/Versions/3.12
export PATH=$PATH:$PYTHON_HOME/bin/python3
# 别名,作用是你在命令行敲phthon即可,不用敲python3
alias python=$PYTHON_HOME/bin/python3
# pip别名
alias pip=$PYTHON_HOME/bin/pip3

2.使配置生效 source ~/.zshrc

3.验证配置有效性

验证python 命令:python

bash 复制代码
~  python
Python 3.12.1 (v3.12.1:2305ca5144, Dec  7 2023, 17:23:39) [Clang 13.0.0 (clang-1300.0.29.30)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hi, python!')
hi, python!

再验证下 pip 命令:pip --version

bash 复制代码
pip --version
pip 23.2.1 from /Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/pip (python 3.12)

That's it!

相关推荐
SelectDB4 小时前
Apache Doris Python UDF:让 SQL 直接调用 Python 生态,支撑 Agent 时代复杂业务逻辑
大数据·数据库·python
Mintimate6 小时前
WorkBuddy 上手: 让脚本项目 Homebrew CN 变成会排障的 Agent
macos·边缘计算·agent
荣码12 小时前
GraphRAG:普通RAG只能回答"点"的问题,我踩了4个坑才搞懂
java·python
金銀銅鐵1 天前
[Python] 基于欧几里得算法,实现分数约分计算器
python·数学
Lyn_Li1 天前
Kaggle Top 5 | 198只股票、200条数据的金融预测——BattleFin高分方案从零复现
python·kaggle·比赛复盘·金融预测
小九九的爸爸1 天前
前端想要入门Agent开发,要具备哪些Python基础?
python·agent·ai编程
阿耶同学1 天前
手把手教你用 LangGraph 搭建三层嵌套 Agent 架构
python·程序员
fthux2 天前
如果你用 Mac,那你可能需要 Noti Shift
macos·开源·github
花酒锄作田2 天前
Pydantic校验配置文件
python
hboot2 天前
AI工程师第四课 - 深度学习入门
pytorch·python·神经网络