Thank you for visiting. I bought a MacBook Pro 16 inch the other day and reinstalled Python. When I was investigating how to install this time, I felt that there were few for zsh users, so I will leave the installation method here.
The procedure this time is as follows.
Type the following in the terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
If you don't know how to open the terminal or are uneasy, please refer to this article. It's very easy to understand. I thought while writing, but is Homebrew included in bash? It is a mystery why it works with zsh. Please let me know if anyone knows.
To be honest, you can install Python only with Homebrew. I think that Mac users who install Python use Python3, but recent Macs include Python3 as standard as well as Python2. The reason for installing pyenv is ** because it's easy to switch between python versions **.
Install pyenv using Homebrew. Type the following in the terminal:
brew install pyenv
As I mentioned a little at the beginning, many other articles describe writing in bash_profile here. Since the default shell from Catalina is zsh, even if you write to bash_profile, you can not basically read it. Type the following line by line into the terminal.
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc echo 'eval "$(pyenv init -)"' >> ~/.zshrc
echo $shell You can see the default shell at.
echo $SHELL /bin/zsh // →zsh /bin/bash // →bash
Check your current Python version before installing.
python --version or python-V => Python 2.7.16
This time, we will install the latest 3.8.5 as of August 1, 2020.
pyenv install 3.8.5
You can check the version that can be installed by doing the following.
pyenv install --list
Specify the Python version. For `` `3.8.5```, enter the one you installed earlier.
pyenv global 3.8.5
Please check your Python version again. The result should be different than before.
python --version or python-V =>Python 3.8.5
There are various installation methods for Python, and if you refer to many articles, I feel that you may get stuck. I hope you can help those who are new to Python. If you find something difficult to understand or make a mistake, please let us know in the comments. Until the end Thank you for reading.