栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

mac安装python3踩坑

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

mac安装python3踩坑

mac自带的python版本是2.7,但市面上常用的python是python3,两者存在很大的差异,所以需要将mac中的python更新到3的版本
由于是刚学习python,对一些问题不是很懂所以在这里记录一下
在这里采用的是mac自带的brew工具来进行安装,本以为会非常简单的一个安装,却没想到遇坑不断
首先通过指令进行安装

brew search python
brew install python@3.9

然后出现了如下错误

==> Installing python@3.9 dependency: ca-certificates
==> Pouring ca-certificates-2022-04-26.all.bottle.tar.gz
Error: No such file or directory @ rb_sysopen - /Users/jiawei/Library/Caches/Homebrew/downloads/66ab11fb867e9c78860f502908686ed6f07cb9ecdae61bdeab62941e7c8a499c--ca-certificates-2022-04-26.all.bottle.tar.gz

网上一番查找发现需要先进行安装ca-certificates,通过

brew install ca-certificates

之后在安装python3.9时又会报如下错误

Installing dependencies for python@3.9: sqlite
==> Installing python@3.9 dependency: sqlite
==> Pouring sqlite-3.39.0.arm64_monterey.bottle.tar.gz
Error: No such file or directory @ rb_sysopen - /Users/jiawei/Library/Caches/Homebrew/downloads/6a28bef262faf8723bd4b879fc4c54a66094531a80d911b96c0c91471c09e93f--sqlite-3.39.0.arm64_monterey.bottle.tar.gz

然后又安装一番sqlite
这次在安装python3就可以了
最后配置一下python环境变量

open ~/.bash_profile

# 在配置文件上加上这两个,路径写成自己安装python的路径
alias python="/opt/homebrew/bin/python3"
PYTHON_PATH="/opt/homebrew/bin/python3"

最后通过 source ~/.bash_profile 进行一下配置就可以了

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1018220.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号