Thursday, February 8, 2018

Windows 10 Linux Subsystem, Flask with PyEnv Setup

The new Linux Ubuntu subsystem in Windows 10 is making quite a good impression, especially for developers. Also, using PyEnv with Virtual Environments allows greater flexibility in setting up development projects.

Linux Setup

Lets first prepare the Linux distribution for development:
    sudo apt-get update
    sudo apt-get upgrade

Development Baseline

Setup the development foundation:
    sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl libncursesw5-dev xz-utils tk-dev

Install PyEnv

Let's install the python version manager:
    curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash

Add the needed  environment variables:
    ~/.profile
    export PATH="/home/user/.pyenv/bin:$PATH"
    eval "${pyenv init -}"
    eval "${pyenv virtualenv-init - }"

Now update the running environment:
    source .profile

Create Project

Download the latest Python 3 stable available version:
    pyenv install 3.4.6

Create the virtual environment with corresponding Python version:
    pyenv virtualenv 3.6.4

Now install the rest of the tools needed!