Skip to content

Technical Prerequisites

omkarghanekar edited this page Dec 17, 2019 · 15 revisions

Technical Prerequisites

Before installing any of these prerequisites, create a virtual environment. Refer link - https://docs.djangoproject.com/en/1.10/howto/windows/ for this

  1. Download Python 3.7.2 from Python downloads If using windows machine, install it on "C:\Program Files (x86)\Python37-32", for ALL users If using ubuntu 16, then use link "Stack overflow - Python 3.7 installation on ubuntu 16"

  2. Install pip - pip is already installed if you are using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from python.org If that's the case then, you need not install it separately.

  3. Next install virtualenvwrapper using. For this go to your project dir for e.g. "E:\cd Projects<project-name>\VirtualEnv" and then use below command

    pip install virtualenvwrapper-win
    

    For ubuntu - refer link GIST - How to install virtual env

  4. Next do

    mkvirtualenv anarde-py3.7.2
    

    This will create a new virtual environment with name "anarde-py3.7.2"

    On windows, you'll find the virtual env created in "C:\Users\Admin\Envs\anarde-py3.7.2" (if you had opened command prompt, for running "mkvirtualenv" using 'run as admin' option)

    For ubuntu virtual env is created as virtualenv anarde-py3.7.2

  5. Then to start using that virtual env, do

    workon anarde-py3.7.2
    

    For ubuntu activate virtual env as follows - source anarde-py3.7.2/bin/activate

  6. Django - (version-2.1) Before installing, make sure virtual environment is active. Then do,

    pip install django==2.1
    
  7. MySQL Client - (version-1.4.4) With Python3.x.x, you require mysqlclient and not mysqlconnector. For this first try installing mysqlclient in virtual env as below

    pip install mysqlclient
    

    If this gives error, try downloading mysqlclient compatible to your OS and 32/64 bit machine, using this url

    pip install e:\Setups\PythonMySqlClient\mysqlclient-1.4.2-cp37-cp37m-win32.whl
    

    Note: Mysql runs in 32 bit mode on win. Hence 'mysqlclient-1.4.2-cp37-cp37m-win32.whl' was compatible on my windows 2010 machine. (Refer link Stackoverflow question - python-3-7-failed-building-wheel-for-mysql-python)

  8. Run all DB scripts

  9. At terminal,

    • go to folder village-development\code_base
    • When still in virtual environment, run, python manage.py migrate admin
    • followed by, python manage.py migrate auth, python manage.py migrate contenttypes, python manage.py migrate sessions
  10. After all is set, create superuser for the django admin project by going go to your project dir - /village-development/code_base and executing following command -

python manage.py createsuperuser

set username (admin) and password (of your choice) for superuser.

  1. For using Datatables with django install django-datatables-view
pip install django-datatables-view 
  1. For integrating with metabase install PyJWT.

     pip install PyJWT 
    
  2. For generating pdf reports install these:

    pip install Weasyprint       
    
  3. For storing images on s3 cloud install boto3

      pip install boto3 
    
  4. Updating metabase

    a. First stop the metabase service, if its running using

       sudo systemctl stop metabase.service
    

    b. Next, get latest version of metabase jsr file using below command

       export VER=<latest-version-of-jar-file> (For e.g. 0.33.6)
       wget http://downloads.metabase.com/v${VER}/metabase.jar
    

    c. Lastly start metabase service again

       sudo systemctl start metabase.service
    
  5. For seeing metabase graphs in reports. (works only on python>=3.6)

      pip install requests-html 
    

Clone this wiki locally