I'm new to programming, and tried to work through the flask tutorial.
I'm stuck on this part (from the readme on github) when trying to run the app:
Fire up a python shell and run this:
from flaskr import init_db; init_db()
Import error: No module named flaskr
OperationalError: unable to open database file
The simplest way to accomplish what you need is to fire up the Python shell in the same folder as you have flaskr:
# I'm assuming that python is available on the command line $ cd path/to/flaskr $ python # Python then runs and you can import flaskr >>> from flaskr import init_db; init_db() >>> exit()
The trick is that when you run Python it only looks in a certain number of places for modules and packages - you can see which places by running:
>>> from sys import path >>> for fp in path: ... print fp
from the Python interpreter. If the path to flaskr is not in that list flaskr can't be imported. By default Python adds the directory it is started in to its search path (which is why we start Python in the directory that contains flaskr.)
Once you have run
init_db you should be able to run the application and see everything working.