Python


Summary

In this page contains various knowledge related to Python.

Installation

Installation steps is here:

macOS

In the first, install pyenv via Homebrew.

brew install pyenv

Open ~/.zprofile, adding the following code:

export PYENV_ROOT=${HOME}/.pyenv
if [ -L ${PYENV_ROOT} -o -d ${PYENV_ROOT} ]; then
    export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init --path)"
    eval "$(pyenv init -)"
fi

Run command on your Terminal.app.

pyenv install 3.9.6
pyenv global 3.9.6
python -m pip install pip --upgrade

Check python packages and update if you have pip or setuptools.

pip list -o
Package    Version Latest Type
---------- ------- ------ -----
setuptools 56.0.0  57.1.0 wheel

Example is here:

pip install pip --upgrade
pip install setuptools --upgrade

Next, install pipenv.

pip install pipenv

Usage

Pythone (Generic)

# Print python version.
python --version

pyenv

# Print installable python
pyenv install --list

# Installe python
pyenv install someone-version

# Set python version in global.
pyenv global someone-version

# Set python version in current directory.
pyenv local someone-version

# Print installed python versions.
pyenv versions

pipenv

pipenv install --dev someone-package
pipenv install someone-package==someone-version
pipenv shell