Create virtualenv with python3

Command is:

virtualenv -p python3 venv

Create virtualenv for existing django project:

First save a list of requirements needed by the project:

pip3 freeze > requirements.txt

Now create a virtualenv:

python3 -m venv myvenv

where myvenv is the chosen name of the environment.

Now activate it:

. myvenv/bin/activate
(venv) [email protected]:~/myappointments$ 

One can deactivate the virtualenv by:


To install django in the virtual environment:

python3 -m pip install --upgrade pip
pip install Django

Now install each dependency with pip3 without failing on errors:

cat requirements.txt | xargs -n 1 pip3 install --retries 1

If you get ImportError: cannot import name 'main', do:

sudo python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall

Install pip3:

apt install python3-pip

Running django with apache:

sudo apt-get install python3-pip apache2 libapache2-mod-wsgi-py3

Some modules that I had to additionally install for my project included:

First install lib for mysql:
If using mysql:

apt-get install libmysqlclient-dev

If using mariadb:

apt-get install libmariadbclient-dev
pip install mysqlclient django-widget-tweaks django-bootstrap4 django-extensions 

Initial steps:
First set a password for mariadb by hardening it:

sudo mysql_secure_installation

Now create an empty database:

create database mydb;
create user [email protected] identified by 'password';
grant all on mydb.* to [email protected];
flush privileges;

Now import an sql dump:
To create a dump:

mysqldump -u root -p mydb > mydb.sql

Transfer the dump.
Import it:

mysql -u root -p mydb <

To test the development server on the ip:

python3 runserver <your-ip-address>:<desired-port>