1

I am very confused about viewing a sample application on github with python/flask.

Here is my situation. I have followed all the instructions to develop a separate application with the official Flask documentation found here Flask Official Docs for Installation. I want to now incorporate bootstrap onto my application but before I do this I want to check out a sample repository found here Github bootstrap-flask. When I try to run python frontend.py I receive this error:

    File "frontend.py", line 8, in <module>
    from flask import Blueprint, render_template, flash, redirect, url_for
    ImportError: No module named flask

I don't understand how to fix this. I know that I have isolated my development application that I am working on in a virtual environment using venv. Am I supposed to do this with the bootstrap-flask github repo to view it? When I try to execute virtualvenv application or pip install something my system says I don't have the packages but I clearly do because I executed the easy_install instructions for both pip and virtualvenv on my Mac OSX. I don't understand the workflow. How does one view a flask application from Github?

Do you virtualvenv, git clone, and then pip install all the dependencies? Help would be appreciated. Thank you.

Dan Rubio
  • 4,709
  • 10
  • 49
  • 106

2 Answers2

1

I suspect you need to execute frontend.py using the python under your virtualenv. So, the steps you would follow are:

  1. git clone https://github.com/mbr/flask-bootstrap.git
  2. cd flask-bootstrap/sample_application
  3. virtualenv env
  4. env/bin/pip install -r ./requirements.txt
  5. env/bin/python frontend.py

I hope this helps, please let me know how you get on, by leaving a comment.

hd1
  • 33,938
  • 5
  • 80
  • 91
  • Hey hd1, thanks for the comment and replying back. This definitely helped me along the only problem I am having is the last step. I get this error with executing env/bin/python frontend.py: from .forms import SignupForm ValueError: Attempted relative import in non-package I'm trying to make sense of it with this stackoverflow link and its references: http://stackoverflow.com/questions/11536764/attempted-relative-import-in-non-package-even-with-init-py but if you happen to know what's wrong while I comb over the answer can you give me just one more boost to get going? – Dan Rubio Nov 08 '15 at 20:12
  • It looks like you may be missing a blank `__init__.py` in the directory. – hd1 Nov 08 '15 at 21:14
  • Also, you might also want to accept the answer, if you found it helpful – hd1 Nov 08 '15 at 21:15
  • Thanks hd1 for the help – Dan Rubio Nov 08 '15 at 21:34
  • No worries, @DanRubio – hd1 Nov 09 '15 at 03:18
0

Assuming you're in the top level directory where your source code for the project is:

Create the virtualenv for your application. I named the environment venv:

virtualenv venv

Activate the virtualenv:

source venv/bin/activate

Install the requirements in the active virtualenv:

pip install -r requiremements.txt

davejagoda
  • 2,420
  • 1
  • 20
  • 27