Python/Flask Setup
-
In your shell (either bash or windows prompt), type:
conda create -n fake_bus python=3.6
where fake_bus is the name of the virtual environment. Check that anaconda is now in your $PATH
-
To activate the environment on bash, use the command:
source activate fake_bus
and to deactivate it, use
source deactivate
On my Windows install, CMD shows the name of the activated environment in the prompt automatically, Powershell doesn't. For CMD or Powershell, it's almost the same, just remove the
source
. -
Grab this repository: https://github.com/hanhanhan/fake_bus_api.git
-
Inside the root of the fake_bus directory, with the fake_bus environment activated, use the command:
pip install -r requirements.txt
-
At your command line, type python -V (uppercase V!). Confirm that python that the version that starts is 3.6, not some earlier system version.
-
To start the server, use:
python main.py
That should get it running on port 5000!
Thing that could not work:
- python is sometimes aliased to an earlier system version, not 3.6. If so, just use
python3.6 main.py
to run the server
More Usage:
-
To run tests, use:
python -m unittest discover tests
from inside the fake_bus directory, or just
python testname.py
to run an individual test. -
To step through code using the debugger, insert
import ipdb; pdb.set_trace()
anywhere you'd like to start stepping through the program.
pp locals()
will pretty print all the local variables, to see other commands useh
.