How to Install Python 3 and Create Virtual Environment In Ubuntu

If you need to use the latest Python 3 version in Linux as a non-root user, you can download the latest python in your space and install it there. In this way, you will have the separate Python development environment from the one that OS relies on. Once you installed Python, it is a good idea to know how to set up virtual environments for development. In this example, I used Ubuntu 16.04 LTS.

If you are interested in doing the same thing in Centos, Redhat and Amazon Linux, check out the blog post here.

(1) Install necessary packages before running Python installation

If you miss some of the packages, pip may fail to download packages after installation.

sudo apt-get install build-essential checkinstall
sudo apt-get install zlib1g-dev
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev \
                libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

(2) Download Python and configure for installation

The prefix parameter will create the folder where Python 3 lives. If you already have the folder with the same name, it will give you error. Make sure to upgrade pip in the call. Make sure to get the download link for the latest Python version. It is 3.6.4 for now.

mkdir ~/python3
cd python3
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
tar xf Python-3.*
cd Python-3*
./configure --prefix=/home/user/python3 --with-ensurepip=upgrade

(3) Build and install

make
make altinstall

(4) Create environment variables for new Python and Pip

export python3=/home/user/python3/bin/python3.6
export pip3=/home/user/python3/bin/pip3.6

(5) Install virtualenv and create a virtual environment

$pip3 install virtualenv
$python3 -m venv lambda
source /home/user/python3/lambda/bin/activate

(6) See if it works.

python
pip

It works! Yay!

Git
How to specify which Node version to use in Github Actions

When you want to specify which Node version to use in your Github Actions, you can use actions/setup-node@v2. The alternative way is to use a node container. When you try to use a publicly available node container like runs-on: node:alpine-xx, the pipeline gets stuck in a queue. runs-on is not …

AWS
Using semantic-release with AWS CodePipeline and CodeBuild

Here is the usual pattern of getting the source from a git repository in AWS CodePipeline. In the pipeline, we use AWS CodeStart to connect to a repo and get the source. Then, we pass it to the other stages, like deploy or publish. For some unknown reasons, CodePipeline downloads …

DBA
mysqldump Error: Unknown table ‘COLUMN_STATISTICS’ in information_schema (1109)

mysqldump 8 enabled a new flag called columm-statistics by default. When you have MySQL client above 8 and try to run mysqldump on older MySQL versions, you will get the error below. mysqldump: Couldn’t execute ‘SELECT COLUMN_NAME, JSON_EXTRACT(HISTOGRAM ‘$”number-of-buckets-specified”‘) FROM information_schema.COLUMN_STATISTICS WHERE SCHEMA_NAME = ‘myschema’ AND TABLE_NAME = ‘craue_config_setting’;’: Unknown …