Python Virtual Environment

Tested on Synology 216

A Python virtual environment is a copy of an existing version of Python with the option to inherit existing packages. 

Update pip

sudo pip3 install --upgrade pip

Install the virtualenv package

The virtualenv package is required to create virtual environments. Install it with pip

sudo pip install virtualenv

Choose a location for the virtual environment

cd /volume1/homes/Daniel

Create the virtual environment

sudo virtualenv virtual_python_test

Activate & deactivate the virtual environment

source virtual_python_test/bin/activate

and to deactivate simply


Installing modules

Example (when inside the activated environment)

sudo pip3 install flask


Place below code inside the above created virtual_python folder

from flask import Flask  # might need to sudo pip3 install flask
from datetime import datetime

app = Flask(__name__)

def hello():
	now =
	current_time = now.strftime("%H:%M:%S")
	return "current time is:" + current_time

if __name__ == '__main__':, host="", port=18085)

Start it with


Test it

Leave a Reply

Your email address will not be published. Required fields are marked *