MAC下安装Python

MAC基本信息:

执行命令:

brew install cmake protobuf rust python@3.10 git wget

遇到以下问题:

==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/rust-1.59.0

Already downloaded: /Users/xxxx/Library/Caches/Homebrew/downloads/fd122b92cd4fe9249e35f891eec3e352f95a168d986493f0b2ecb0ba95922c37--rust-1.59.0.monterey.bottle.tar.gz

Error: python@3.10: the bottle needs the Apple Command Line Tools to be installed.

  You can install them, if desired, with:

    xcode-select --install

You can try to install from source with:

  brew install --build-from-source python@3.10

Please note building from source is unsupported. You will encounter build

failures with some formulae. If you experience any issues please create pull

requests instead of asking for help on Homebrew's GitHub, Twitter or any other

official channels.

==> Downloading https://mirrors.aliyun.com/homebrew/homebrew-bottles/wget-1.21.3

Already downloaded: /Users/xxxx/Library/Caches/Homebrew/downloads/b7c9518741b5ffbedb680ca184dd793dac01c932d4efdfdfbe88593987186784--wget-1.21.3.monterey.bottle.tar.gz

fatal: not in a git directory

Error: Command failed with exit 128: git

根据这个错误做搜索,发现需要执行以下命令 :

brew -v

获取如下信息:

Homebrew 3.5.2-113-g5d3501f

fatal: unsafe repository ('/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core' is owned by someone else)

To add an exception for this directory, call:

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

Homebrew/homebrew-core (no Git repository)

fatal: unsafe repository ('/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask' is owned by someone else)

To add an exception for this directory, call:

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask

Homebrew/homebrew-cask (no Git repository)

按照上述信息执行:

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core

git config --global --add safe.directory /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask

重新执行以下命令:

brew install cmake protobuf rust python@3.10 git wget

 判断python是否安装成功:

python3 -V

安装效果:

Python 3.9.13

修改别名,执行命令

vim ~/.bash_profile 

添加下面信息:

alias python=python3

alias pip=pip3

执行命令:

# 
source .bash_profile 

#
python -V 

#
pip

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值