Skip to content

Windows Installation Guide

Aakash Bansal edited this page Oct 2, 2018 · 18 revisions

Windows Installation Guide

You can even refer to the Video Tutorial on YouTube by Adhyan Dhull

Prerequisites

Installation

  1. Download Repository (https://github.com/scorelab/Bassa) to local storage. This can be done by clicking the green button labelled "Clone or download", followed by clicking on the "Download ZIP" on the menu that just appeared. Once downloaded unzip file in desired directory.

  2. Navigate to folder 'Bassa-master' (which should of been created when unzipping the zip file downloaded.) On linux systems you would normally run setup.sh but windows doesn't support `sudo' or 'apt-get' , which means we will have to install some of the dependencies manually.

  3. Using the setup.sh as a checklist we will manually install the dependecies inside of it.

    • Pip: In linux we would normally install pip, but pip is bundled with python 3.x for windows so there is no need
    • SetupTools: To install setuptools in cmd run pip install setuptools
    • Aria2: Youtube video on how to install: https://www.youtube.com/watch?v=VoMPvY0KtaQ Now there is no installer for aria2 so it will be harder to install. First go to [https://aria2.github.io/] (https://aria2.github.io/) and download the latest version as a zip (the file should look like aria2-1.33.1-win- 32bit-build1.zip or aria2-1.33.1-win-64bit-build1.zip) . Make sure you download the 64 bit or 32 bit version depending on your computer. Unzip the zip file - you could do this in any directory really, but you could put it in the 'programs' folder if you want. After unzipping look inside the folder there should be an .exe, if there isn't, then you probably have downloaded the wrong file. Now copy the directory of the folder, not the .exe. Now just enter the directory into your PATH environment variable (tutorial here: https://msdn.microsoft.com/en-us/library/office/ee537574(v=office.14).aspx)
    • MySQL server: Download the windows installer from https://dev.mysql.com/downloads/installer/
      Go through the installer instructions. Make sure that you have selected to install the mysql server component, as well as the connectors (C connectors). You will be asked to make a root password and a admin's username and password. TAKE NOTE OF THESE
    • Libmysqlclient: should be installed with the automatic installer used above. If that didn't work you can install the c connector (which is contains the libmysqlclient-dev) through a msi installer that can be downloaded from https://dev.mysql.com/downloads/connector/c/
    • Node: Install node using the installer which can be downloaded from https://nodejs.org/en/
    • Bower: You can install bower using npm, which is bundled with node. To do this open a command prompt and type npm install -g bower
    • Gulp: Again you can install gulp using npm, which is bundled with Node. To do this open a command prompt and type npm install -g gulp
  4. Navigate (in file explorer or CMD) to the folder 'components', then 'core'.

  5. Open CMD in that directory (one way to do that is Shift + right click, click 'Open command prompt here')

  6. Type and run the command python setup.py develop . NOTE If you get the error 'python is not recognized as an internal or external command', generally you must add python to PATH (tutorial here: https://superuser.com/questions/143119/how-to-add-python-to-the-windows-path)

If you get the error: "Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat)." Visit the troubleshooting wiki page, which will have the instructions on how to fix it (you must install Build Tools for Visual Studio 2017)

You can now run the Bassa backend with python Main.py

Furthermore, you can also start the backend as well as the UI, by running one single bat file. (refer to the Automatic Server Start section of this article)

Database Setup

You should already have installed the MySQL community server through the windows installer - download https://dev.mysql.com/downloads/installer/ . During the setup you made a root password - take note of this!

Now if you have installed everything correctly, you should be able to search up - on windows, the application 'MySQL <version_number> Command Line Client'. Open this. The prompt will ask you for your root password that you created during the installation. If you have forgotten it the easiest way is to uninstall the server and reinstall again. Now type the command create database Bassa; (don't forget the semicolon). No errors should appear. You can now exit the Command Line Client.

Now open CMD in the root of the repository. Type the command mysql -u root -p Bassa < Bassa.sql It will ask you to provide a root password to continue. If it works there will be no errors.

Now open components/core/DBCon.py , inside there will be a text field holder of BASSA_DB_USERNAME, BASSA_DB_PASSWORD, BASSA_DB_NAME. When you installed MySQL you were asked to create a user, with a username and password. Replace BASSA_DB_USERNAME and BASSA_DB_PASSWORD , with the those accordingly. BASSA_DB_NAME is the name of the database. If you have followed the previous instructions then the name of you database will be Bassa . Replace BASSA_DB_NAME with it.

So the final changes in DBCon.py would look like :

If the environment variables are being used, modify as following :

_db=MySQLdb.connect("db", os.environ.get('YOUR_DB_USERNAME'), os.environ.get('YOUR_DB_PASSWORD'), os.environ.get('Bassa'))

If the environment variables are not configured and hardcoded strings are being used, replace as :

_db=MySQLdb.connect(host="localhost", user="YOUR_DB_USERNAME", passwd="YOUR_DB_PASSWORD",db= "Bassa")

NOTE : On Windows Machine, the MySQL Server version 8.x introduces something called 'caching_sha2_password' plugin that does not work with the existing codebase and gives the follwing error :

raise exc.InvalidRequestError("This connection is closed")
sqlalchemy.exc.InvalidRequestError: This connection is closed

The exact issue being :

"Authentication plugin 'caching_sha2_password' cannot be loaded."

This issue can be solved in one of two ways:

  1. Either downgrade the MySQL Server to 5.7.x.
  2. Change the password encryption method for MySQL Server. Refer this : https://stackoverflow.com/questions/49194719/authentication-plugin-caching-sha2-password-cannot-be-loaded

The first method is easier.

Bassa UI installation

Now if you want a nice looking interface, instead of a boring terminal (sorry terminal), then there are a few extra steps required to install the dependencies.

  1. Navigate to the 'bassa-windows' folder (main folder created when unzipping zip file). If you were just following the previous instructions, then you will be inside in the 'components/core' directory. Just click the back button twice (or go up a directory twice) - this should get you to the correct folder.

  2. Inside the 'bassa-windows' folder navigate the folder(directory) labeled 'ui' .

  3. Open up your CMD prompt inside of the folder (this can be done by SHIFT + right click, 'Open Command Prompt Here'). In the command prompt run the command npm install .

If you get an error running npm install, then you probably haven't installed it. NPM comes bundled with Node.js. So all you have to do is install node.js (from https://nodejs.org/en/), and there you go.

  1. Next you must install Bower. In a command prompt type and run npm install -g bower (the -g flag installs it globally)

  2. Install Gulp with npm install --global gulp

Run Bassa UI with gulp serve

Again, you can also start the backend as well as the UI, by running a bat file. (refer to the Automatic Server Start section of this article)

DB setup and aria2 installation is identical to the other platforms and the instructions can be found on the README

Manual Server Start

Quick summary (extensive instructions just below):

  • Run this command in a new cmd in the 'components/core folder' - python Main.py
  • Run this comand in a new cmd in the '/ui' folder - gulp serve
  • Run this command in a new cmd in the main folder of the repository - aria2c --enable-rpc

You can either use the bat file to start your server, or you can manually run the commands. There are a total of two commands that have to be run in separate command prompt windows to get it up ad running.

First open a command prompt and navigate to the components/core folder in the repo (the 'cd' command is very useful). Once the working directory for the cmd is in the components/core folder, run python Main.py . If the command prompt prints out Server initialized for gevent. then the test server is running and is ready. NOTE.Keep the CMD window open to keep the server from stopping.

Next open a new command prompt, and navigate to the ui/ folder in the repo (again 'cd' command is useful). Once the working directory for the cmd windows is the ui/ folder, run 'gulp serve. If it is functioning correctly then you should see an output of text. It should begin with[09:53:11] Using gulpfile ~\Documents\Coding\Bassa-master\ui\gulpfile.js` Remember the time (the [09:53:11]) will vary as well as the directory part, depending on where you put the repo.

If using the chrome browser, for me it opens a new tab which has it's url set to localhost:3000 . If this doesn't happen for you look at the cmd window where you ran gulp serve. There should be a line that looks something like [BS] Local URL: http://localhost:3000/ copy and paste the url into your browser of choice. It should load onto the Bassa login screen.

Automatic server start

Inside the repo there is a bat file which if ran will automatically run the commands python Main.py and gulp serve - starting the core and ui modules of Bassa. For each of these commands it will open a new cmd window. To start the server just double click the file, and a cmd window should pop up. Now if you receive no errors then the window will say SUCCESSFULLY STARTED UI and SUCCESSFULLY STARTED TEST SERVER.

Now there are a few errors that may occur before it starts the ui and test server. If you receive a message beginning and ending with a line of asterisks (*), then that unfortunately means that there is an error. This is because before starting the server the bat file tests for the dependencies. It does this by basically running the cmd command for that program (for example if python is installed, the command python should not return any errors.) With each error there will be an explanation on how to fix it. All of the errors suggest that you download (if you haven't already) the program that cannot be ran. Because the program checks to see if something is installed by just running the CMD command, this means that the program's .exe file may exist somewhere on the HDD but it will still give an error because the directory of the .exe is not in the PATH environment variable. The PATH environment variable is where CMD will look for the application you have asked to run through the command prompt. This saves time as the computer knows where to look for it. A tutorial on how to add application to path: https://msdn.microsoft.com/en-us/library/office/ee537574(v=office.14).aspx .

If you get an error from the gulp server ui cmd, or the 'python Main.py` test server cmd, then it is an issue regarding the server itself. Double check on dependencies as the .bat file currently doesn't check all of them (refer to 'For developers' section for the list of dependencies it currently checks).

For Developers

Currently the .bat file checks for the following dependencies (if any are added please add them here):

  • Python
  • NodeJS
  • NPM (which should be bundled with nodejs)
  • Gulp

If you get an error like python: can't open file 'components/core/Main.py': [Errno 2] No such file or directory or The system cannot find the path specified. then files have been changed inside the repo. To understand these errors we need to look at the code:

start cmd /k "ECHO Python Test Server & python components/core/Main.py" This line starts the python test server. The start cmd /k part opens a new cmd window and anything following - surrounded with speech quotes, will be ran. The ECHO Python Test Server is not very important, what is important is the python components/core/Main.py. The 'python' part calls the Python.exe. Following the keyword 'python' is the directory to the python file that you want python.exe to run. However if Main.py is moved then the components/core/Main.py is incorrect, which produces the error python: can't open file 'components/core/Main.py': [Errno 2] No such file or directory . To fix this change it to the correct directory of Main.py.

START cmd /k "ECHO Frontend Node Module & cd ui & gulp serve" Again this line opens a cmd and ECHO's a line to it, but the important part is the cd ui. This changes the working directory for the cmd to run the command gulp serve ('cd' stands for 'change directory'). If the ui components are moved to a different directory then change the target directory for the 'cd' command. If the command is not changed then you may get the error: The system cannot find the path specified.