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. 

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
mkdir virtual_env_test
cd virtual_env_test

Create the virtual environment

sudo virtualenv virtual_python

Activate & deactivate the virtual environment

source virtual_python/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.