Skip to content

Running on Ubuntu OS

Nikhil VJ edited this page Apr 26, 2018 · 11 revisions

A. Directly on system Python3

Note: It is recommended to go the virtual environment way instead. Still, if you're fine with it...

git clone https://github.com/WRI-Cities/static-GTFS-manager.git
cd static-GTFS-manager
pip3 install pandas tornado xmltodict tinydb pycryptodomex --user
python3 GTFSManager.py

Note: We'll be installing whatever's the latest version of the respective packages the program needs. There can be breaking changes in newer versions some years down the line that make the program inoperable with them. If that happens on your end, please follow the virtual environment way shown below.

Note: You might encounter a problem with installing pandas. Scroll down to "Solving pip pandas installation problem" heading to resolve that.

B. Using a virtual environment

This is the recommended way, to ensure you have the exact versions of dependencies that the programmer had at the time of making the software, and to have it not interfere with the rest of your system.

  1. Open Terminal (linux command prompt) and clone this repo to your side:
    git clone https://github.com/WRI-Cities/static-GTFS-manager.git

  2. Navigate into the folder created.
    cd static-GTFS-manager

  3. Install virtualenv in your system if not already installed:
    pip3 install virtualenv --user

  4. Initiate a python3 virtual environment in /tmp and install the dependencies there

virtualenv -p python3 /tmp/VIRTUAL
source /tmp/VIRTUAL/bin/activate
which python3
  1. Last command shows from where the current python environment is running. It should come as /tmp/VIRTUAL/bin/python3

  2. We'll be using pip the package installer to install the required python modules. Proceed with the next steps, and IF you encounter an error, please jump down to the heading "Solving pip pandas installation problem", do one of the workarounds offered, then come back here and proceed.

  3. Install the required python dependencies, in the virtual environment where it will not interfere with you system's main python: pip3 install -r requirements.txt
    Note: you can also just read requirements.txt and install the packages manually using pip3 install package==version

  4. Run GTFSManager.py in python3:
    python3 GTFSManager.py

  5. The program should load in a new web browser tab. You can now operate the program from your web browser. In case it doesn't load up, see the terminal for the URL, it is most likely http://localhost:5000/ or so.

  6. See the terminal for instructions and reporting of various processes. There are some recurring warnings which you can ignore, like WARNING:tornado.access:404 GET /favicon.ico (::1) 1.35ms

Note: there is a password input box at top right corner. It's a basic idiot-proofing measure. For any operation involving editing, import or export of data, the password should be typed in. Please scroll down to find ways to change the password or work around it.

Closing

  1. The program will keep running while you operate on the browser. To terminate the program, come back to the Terminal and press Ctrl+C or close the window.

  2. To get out of the python3 virtual environment, run: deactivate. To get back in, run source /tmp/VIRTUAL/bin/activate. You may navigate to /tmp/ folder and delete off the VIRTUAL folder; it won't have any effect on the rest of your system. And on system reboot it'll probably get deleted on its own anyways.

Note: During this whole time, we did create a virtual environment at /tmp/VIRTUAL/ but in the Terminal we stayed at the program's working folder only. We didn't navigate anywhere else.

All commands together

git clone https://github.com/WRI-Cities/static-GTFS-manager.git
cd static-GTFS-manager
pip install virtualenv --user
virtualenv -p python3 /tmp/VIRTUAL
source /tmp/VIRTUAL/bin/activate
which python3
pip3 install pip==9.0.3
pip install -r requirements.txt
python3 GTFSManager.py

Note: If you want to keep a permanent virtual environment, you can setup the VIRTUAL folder under /home/ or anywhere on your system that doesn't have a space in the path name. This is a big current bug about pip installer in virtual environments: It can't tolerate spaces in the absolute path. Which is also why I didn't show a relative path way.. there's high chances one of your folders or even the hard drive name as a space in it.


C. Notes, extended explanations

Do we really need to be so strict about package versions?

Not really. This is just the recommended settings that we know to work for sure. Go ahead and try with the latest.. there might even be some improvements in performance! If the program is working fine with a later version, then please file an issue requesting the developers to edit the requirements.txt file and raise the version numbers to have them match current values. Or, you can fork, make the changes at your end and put in a pull request. We'll have to test the whole thing out properly though before proceeding.


Solving pip pandas installation problem

As of pip v10.0.1 in April 2018, there is an incompatibility issue happening when installing one of the modules, pandas, affecting 32-bit linux machines. You might see something like this on trying to install pandas:

Collecting pandas
  Using cached https://files.pythonhosted.org/packages/08/01/803834bc8a4e708aedebb133095a88a4dad9f45bbaf5ad777d2bea543c7e/pandas-0.22.0.tar.gz
  Could not find a version that satisfies the requirement numpy==1.9.3 (from versions: 1.11.1rc1, 1.11.1, 1.11.2rc1, 1.11.2, 1.11.3, 1.12.0b1, 1.12.0rc1, 1.12.0rc2, 1.12.0, 1.12.1rc1, 1.12.1, 1.13.0rc1, 1.13.0rc2, 1.13.0, 1.13.1, 1.13.3, 1.14.0rc1, 1.14.0, 1.14.1, 1.14.2)
No matching distribution found for numpy==1.9.3

This is because pandas v0.22.0 has within its package a doc pandas-0.22.0/pyproject.toml telling it to only accept numpy v1.9.3 (as a dependency install) whereas pip has since moved on and is only having later versions of numpy on board. Welcome to the world of obsoleted dependencies. This is also one of the reasons why it's better to be installing this stuff in virtual environments rather than the main system python3 engine which in Linux systems also powers the whole OS.

First, install the latest numpy package independently:
pip3 install numpy

Then, do ANY ONE of these two workarounds:

  1. Run this: pip3 install pandas --no-build-isolation
    This should tell pip3 to ignore the exact numpy version mandate in the pandas installer and instead go with what's already there.

OR

  1. Set pip package installer to 9.0.3 version. Back then, it did not pay heed to the exact version mandate. pip3 install pip==9.0.3

Hopefully this versions conflict will get resolved as pip and pandas progress and new versions come. Reference: https://github.com/pandas-dev/pandas/issues/20697#issuecomment-384350250