Get started with Python! ~ ① Environment construction ~


I think the era is Python. I usually love JS (I love React), but I think Python will take the lead in machine learning and data processing. (I also want to write AWS Lambda in Python!)

I will study for the ideal of React on the front and AWS (Lambda is Python) on the back. (I just touched it a year ago and I don't remember.)

Also, I was wondering whether to use 2.X or 3.X, but I have been told by a respected person that both are necessary, so I hope I can re-introduce while comparing the differences.

Python environment construction

3.x is now under development. Development of 2.x has stopped. However, the current Python frameworks can use 2.x, I am in a sad situation that 3.x cannot be used.

I thought it would be better to switch the Python version quickly, and when I investigated if there was any good way, it was normal.

There was a Python version called pyenv that could manage it. It's similar to nvm, which switches the version of Node.js.

pyenv installation procedure

It's super easy, just clone from GitHub.

$ git clone ~/.pyenv

After cloning, write the execute command to .bash_profile. It is OK if you add the following.

export PYENV_ROOT=$HOME/.pyenv
eval "$(pyenv init -)"

Now you are ready to switch versions of Python.

Install Python from pyenv.

Install Python from pyenv. That said, it's easy and you can install it in one shot with the following command.

pyenv isntall 3.5.1

With the above command, you have installed the latest version of Python, 3.5.1. (Pip is installed as standard from 3.4.x, so it's OK as it is.)

Specify the Python version used by pyenv.

There are three ways to specify pyenv.

(1) Reflect in the entire system.

pyenv global 3.5.1

(2) Reflect only in the current directory.

pyenv local 3.5.1

③ Reflect only in a specific shell.

pyenv shell 3.5.1

① is reflected in the entire system, and ② is reflected only in the current directory. Specify ③ with the shell you want to use temporarily.

I usually use 3.x, but this project can be separated smoothly into 2.x.

Also, even if you exit the terminal, this reflection will continue to live. It's extremely convenient.

If you want to return to the default Python on your Mac, the following is OK.

pyenv global system

Now you can switch versions at any time.

When you want some module,

pip install XXXX

Let's install and use it.


I'm just starting to review it, I think it's a waste to get stuck in different versions. Thoroughly manage Python version with pyenv so that version switching can be done smoothly from the beginning.

From Next time, we will start the grammar section.

Recommended Posts

Get started with Python! ~ ① Environment construction ~
Let's get along with Python # 0 (Environment construction)
Get started with Python! ~ ② Grammar ~
Link to get started with python
Python environment construction
Environment construction (python)
How to get started with Python
python environment construction
Python --Environment construction
Get started with Python in 30 minutes! Development environment construction & learn basic grammar
Python environment construction
Python3 environment construction with pyenv-virtualenv (CentOS 7.3)
pytorch @ python3.8 environment construction with pipenv
python environment construction
Get started with Python in Blender
Let's get started with Python ~ Building an environment on Windows 10 ~
[Ubuntu 18.04] Python environment construction with pyenv + pipenv
Get Started with TopCoder in Python (2020 Edition)
How Python beginners get started with Python with Progete
[Blender x Python] Let's get started with Blender Python !!
[Python] Get environment variables
python windows environment construction
1.1 Getting Started with Python
homebrew python environment construction
Python development environment construction
Getting Started with Python
Python environment with docker-compose
Get started with MicroPython
python2.7 development environment construction
Get date with python
Get started with Mezzanine
Getting Started with Python
Mac environment construction Python
Virtual environment with Python 3.6
Python environment construction @ Win7
Collecting information from Twitter with Python (Environment construction)
Python hand play (let's get started with AtCoder?)
Poetry-virtualenv environment construction with python of centos-sclo-rh ~ Notes
Get started with Python on macOS Big Sur
First python ① Environment construction with pythonbrew & Hello World !!
From Python environment construction to virtual environment construction with anaconda
A layman wants to get started with Python
[Cloud102] # 1 Get Started with Python (Part 1 Python First Steps)
Get a quick Python development environment with Poetry
[Cloud102] # 1 Let's get started with Python (Part 2 Jupyter Notebook Construction AWS Edition)
Get country code with python
Python + Anaconda + Pycharm environment construction
Getting Started with Python Functions
Get started with Django! ~ Tutorial ⑤ ~
Install Python environment with Anaconda
Get Twitter timeline with python
Manage python environment with virtualenv
Get started with influxDB + Grafana
Get Youtube data with python
Python environment construction (Windows10 + Emacs)
Getting Started with Python Django (1)
CI environment construction ~ Python edition ~
Get started with Django! ~ Tutorial ④ ~
Getting Started with Python Django (4)
Build python3 environment with ubuntu 16.04
ML environment construction with Miniconda