Mac m1版本安装Python2

354 阅读1分钟

装python2主要是为了解决项目使用node-sass安装依赖错误的问题

安装步骤:

  1. exec the command in terminal

brew install pyenv
arch -x86_64 pyenv install 2.7.18

  1. write path in .bash_profile or .zshrc

#.bash_profile

export PYENV_ROOT=/Users/lilv/Code/Tools/pyenv  
export PATH="$PYENV_ROOT/shims:$PATH"

#.zshrc

if [ -f ~/.bash_profile ]; then  
    . ~/.bash_profile;  
fi  
  1. install 2.7.18 in terminal and use it

pyenv install 2.7.18
pyenv golbal 2.7.18

  1. check python version
    pyenv versions

Tips:
The Python ssl extension was not compiled. Missing the OpenSSL lib?
solution: brew uninstall --ignore-dependencies openssl