[2020.8 latest] How to install Python

Introduction

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.

procedure

The procedure this time is as follows.

  1. Install Homebrew
  2. Install pyenv
  3. Python installation

1. Install Homebrew

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.

2. Install pyenv

Reasons to install pyenv

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 **.

Installation

Install pyenv using Homebrew. Type the following in the terminal:

brew install pyenv

Pass through

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

* If you don't know if the default shell is bash or zsh

echo $shell You can see the default shell at.

echo $SHELL 
 /bin/zsh             // →zsh
 /bin/bash            // →bash

3. Python installation

Check Python version before installation

Check your current Python version before installing.

python --version or python-V 
 => Python 2.7.16

Installation

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

Version switching

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

Finally

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.

Recommended Posts

[2020.8 latest] How to install Python
How to install Python
How to install python
How to install Python [Windows]
How to install python using anaconda
How to install pip
How to install and use pandas_datareader [Python]
python3 How to install an external module
[Kivy] How to install Kivy on Windows [Python]
How to install archlinux
How to install BayesOpt
How to install Nbextensions
How to install Prover9
How to install python3 with docker centos
[2020 version] How to install Python3 on AWS EC2
How to install OpenCV on Jetson Nano Python
How to install Python for pharmaceutical company researchers
[Python] How to install OpenCV on Anaconda [Windows]
python3: How to use bottle (2)
Tabpy 1.0 (2020-01 version) How to install
[Python] How to use list 1
How to update Python Tkinter to 8.6
How to use Python argparse
How to install mkl numpy
Python: How to use pydub
[Python] How to use checkio
How to run Notepad ++ Python
How to change Python version
How to install Pelican blog
How to develop in Python
[python] How to judge scalar
[Python] How to use input ()
How to use Python lambda
[Python] How to use virtualenv
python3: How to use bottle (3)
python3: How to use bottle
How to use Python bytes
install python
Steps to install the latest Python on your Mac
How to write a Python class
[Python] How to FFT mp3 data
[Python] How to do PCA in Python
Python: How to use async with
How to install mysql-connector-python on mac
How to install and use Tesseract-OCR
[Python] How to derive nCk (ABC156-D)
[Python] How to use Pandas Series
How to collect images in Python
How to use Requests (Python Library)
How to use SQLite in Python
[Introduction to Python] How to parse JSON
How to install python-pip with ubuntu20.04LTS
How to install graph-tool on macOS
How to install wkhtmltopdf (Amazon Linux2)
How to install VMware-Tools on Linux
How to install pycrypto on Windows
How to get the Python version
How to install OpenCV on Mac
How to install MBDyn (Linux Ubuntu)
How to install PyPy on CentOS
How to get started with Python