Skip to content

Latest commit

 

History

History
65 lines (36 loc) · 2.58 KB

README_API_INSTALL_PYTHON_LINUX.md

File metadata and controls

65 lines (36 loc) · 2.58 KB

README for API Installation: 3b. Installing Python/Django on Linux

Back to Install Table of Contents

PREVIOUS: 2. Get WeVoteServer Code from Github

Preparing a virtual environment

Taken from here: https://www.digitalocean.com/community/tutorials/how-to-install-the-django-web-framework-on-ubuntu-16-04#install-through-pip-in-a-virtualenv

Perhaps the most flexible way to install Django on your system is with the virtualenv tool. This tool allows you to create virtual Python environments where you can install any Python packages you want without affecting the rest of the system. This allows you to select Python packages on a per-project basis regardless of conflicts with other project's requirements.

We will begin by installing pip from the Ubuntu repositories. Refresh your local package index before starting:

$ sudo apt-get update

If, instead, you plan on using version 3 of Python, you can install pip by typing:

$ sudo apt-get install python3-pip

If you installed the Python 3 version of pip, you should type this instead:

$ sudo pip3 install virtualenv

Now, whenever you start a new project, you can create a virtual environment for it. Start by creating and moving into a new project directory:

$ mkdir ~/VirtualEnvironments

$ cd ~/VirtualEnvironments

Now, create a virtual environment within the project directory by typing:

$ virtualenv --python=/usr/bin/python3.11 WeVoteServer3.11

Now activate this new virtual environment for WeVoteServer:

$ cd ~/PythonProjects/WeVoteServer/
$ source ~/VirtualEnvironments/WeVoteServer3.11/bin/activate
(WeVoteServer) $ export PATH="TBD/Postgres.app/Contents/Versions/latest/bin:$PATH"

Installing Python 3 on Linux

(WeVoteServer3.11) $ pip3 install django
(WeVoteServer3.11) $ pip3 install --upgrade pip
(WeVoteServer3.11) $ pip3 install -r requirements.txt
(WeVoteServer3.11) $ python3 -m pip install pyopenssl pyasn1 ndg-httpsclient

If installing requirements.txt does not work because of different dependencies, attempt install -r requirements.txt several times. Also,relying on IDEs like PyCharm may help installing the packages.

Test with this command:

(WeVoteServer) $ python manage.py makemigrations
(WeVoteServer) $ python manage.py migrate
(WeVoteServer) $ python3 manage.py runserver

NEXT: 4. Set up Environment

Working with WeVoteServer day-to-day

Back to Install Table of Contents