install python

Preface

I started programming on my own, but it took me a long time to master it to the end of this article. It's very difficult so you shouldn't lick it.

I will _help _ it.

Introduction

This article is how to install python on MacOS

This article is my recommended method and if you don't like this method, please visit other sites.

This article has a respect for the text of other sites.

Referenced site

Prepare a Python development environment! (Mac)

table of contents

[Operation check environment](https://qiita.com/drafts/3840d0208306607a494a/edit#%E5%8B%95%E4%BD%9C%E7%A2%BA%E8%AA%8D%E7%92%B0 % E5% A2% 83 "Operation check ring") [Homebrew installation](https://qiita.com/drafts/3840d0208306607a494a/edit#homebrew%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC % E3% 83% AB "Operation check ring") [Install pyenv](https://qiita.com/drafts/3840d0208306607a494a/edit#pyenv%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83% 88% E3% 83% BC% E3% 83% AB "Operation check ring") [Finally install Python](https://qiita.com/drafts/3840d0208306607a494a/edit#%E3%81%A4%E3%81%84%E3%81%ABpython%E3%82%92%E3%82% A4% E3% 83% B3% E3% 82% B9% E3% 83% 88% E3% 83% BC% E3% 83% AB "Operation check ring")

Operation check environment

MacOS10.15.7

Homebrew installation

$brew --version

Please execute this command if

$Homebrew 2.2.10

If the message such as (may be slightly different) is displayed, proceed to the next stage.           ↓ [Install pyenv] (https://qiita.com/drafts/3840d0208306607a494a/edit#pyenv%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83 % BC% E3% 83% AB "Operation check ring")

In other cases, please continue reading

Continued

Please go to this site and click the button ① in the image below to copy the command.             ↓        https://brew.sh/index_ja スクリーンショット 2020-11-02 19.01.17.png

Then スクリーンショット 2020-11-02 19.42.33.png

"Finder"-> "Applications"-> "Utilities"-> "Terminal" Open the terminal as Enter the command you just copied from the site スクリーンショット 2020-11-02 19.45.12.png

This completes the Homebrew installation.

Install pyenv

Next, let's install "pyenv" using Homebrew prepared in the previous chapter. First of all, make sure that pyenv is not installed. Try running the following command.

$pyenv -v
pyenv: command not found

The person who is displayed does not have pyenv installed yet. In other cases, pyenv is already installed. Let's jump to the link below.      ↓ [Finally install Python](https://qiita.com/drafts/3840d0208306607a494a/edit#%E3%81%A4%E3%81%84%E3%81%ABpython%E3%82%92%E3%82% A4% E3% 83% B3% E3% 82% B9% E3% 83% 88% E3% 83% BC% E3% 83% AB "Operation check ring")

Continued

$brew install pyenv

And execute the command If there is no problem with this, the installation is completed. Let's run the following command to verify that pyenv was installed.

pyenv -v
pyenv 1.1.0 

It is OK if the characters like (may be slightly different) are displayed!

In the next chapter, we will install Python using pyenv, but before that, let's set up the installed pyenv. Execute the following commands in order in the terminal. Nothing is displayed when I execute each, but there is no problem.

echo $SHELL

If the execution result of the above command is "/ bin / bash", execute the following four commands.

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ~/.bash_profile

If the execution result is / bin / zsh, execute the following four commands.

echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc
source ~/.zshrc

As for what I did, I added the setting code to the file ".bash_profile" or ".zshrc". You may not be sure what is happening, but you don't have to worry about it here. This completes the pyenv settings!

Finally install Python

Now, let's install Python using the installed pyenv. The pyenv you just installed can install multiple versions of Python, so you need to choose the version of python. Now let's see what version of Python you can install. Try running the following command in your terminal.

pyenv install --list

I think that a lot of characters were displayed. If you scroll up the terminal, you will see a number that starts with a number like "3.6.5", as shown in the image below. 1526541004583.png Shown here are the currently installable versions of Python. Let's install the relatively new "3.6.5" this time. (If "3.6.5" is not displayed, you cannot install it. In that case, try installing the displayed version such as "3.5.0" instead.) First, execute the following command to install "3.6.5" Python.

pyenv install 3.6.5

It will take a while, but if the following screen is displayed, the installation is complete. Then try running the following command:

pyenv versions

With this command, you can see a list of currently installed Python. If "3.6.5" is displayed on the screen, you can confirm that the installation was successful. However, in this state, I will use the version of Python that is installed by default on the Mac instead of 3.6.5. Let's change the setting to use the version of Python installed this time by executing the following command.

pyenv global 3.6.5

You are now ready to use 3.6.5 Python! Let's check it by executing the following command.

python --version

If the settings are correct, you should see 3.6.5.

Finally

thank you for your hard work. This completes the introduction of python. If you get an error with a combination of other software, I will continue to publish articles from time to time, so please refer to that. https://qiita.com/yuttyaDX

Recommended Posts

install python
Install Python locally
Install NAOqi python
Install Python Control
CentOS8 --Install --Python3
Install python on WSL
How to install Python
Install Python on Pidora.
Install Scrapy on python3
Python
Install Python on Mac
How to install python
Install Python 3 on Mac
Install python from source
Install Python3.4 on CentOS 6.6
Install Python Jupyter lab
Install python external library
Install python (pyenv, pyenv-virtualenv)
Install Voluptuous with Python 2.5
Install python on windows
Python PyTorch install tips
Install Python 2.7.3 on CentOS 5.4
Install python with pyenv
Install Python 3.3 on Ubuntu 12.04
Install Python 3.4 on Mac
Install Python 3.6 on Docker
Install Python (for Windows)
[2020.8 latest] How to install Python
How to install Python [Windows]
Install Python 3.8 on RHEL 8 (AppStream)
Install watchdog on Windows + Python 3.3
Install Python and Flask (Windows 10)
Install Python environment with Anaconda
Install pygame on python3.4 on mac
Windows10: Install python dlib library
Install Python 3.8 on CentOS 7 (SCL)
Install external libraries with Python
Install multiple versions of Python
Install pandas 0.14 on python3.4 [on Mac]
Install Python 3.7 and Django 3.0 (CentOS)
Install OpenCV on Ubuntu + python
Python --Install MySQLDB on EC2
Install pyenv from Homebrew, install Python from pyenv
Install Python 3.8 on CentOS 8 (AppStream)
[Python] [Chainer] [Windows] Install Chainer on Windows
Python install in 2 lines @Windows
Install dlib for Python (Windows)
kafka python
How to install python using anaconda
Install Python Pillow on Amazon Linux
Install pytorch
Python basics ⑤
python + lottery 6
Python Summary
Install Python 3.8 on Ubuntu 18.04 (OS standard)
Built-in python
Python comprehension
Install Activiti 6
Studying python
Python 2.7 Countdown
Python memorandum