MAC下安装Python

MAC基本信息:

MAC下安装Python_第1张图片

执行命令:

brew install cmake protobuf rust [email protected] 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: [email protected]: 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 [email protected]

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 [email protected] git wget

 判断python是否安装成功:

python3 -V

安装效果:

Python 3.9.13

修改别名,执行命令

vim ~/.bash_profile 

添加下面信息:

alias python=python3

alias pip=pip3

执行命令:

# 
source .bash_profile 

#
python -V 

#
pip

你可能感兴趣的:(macos)