1

I been following instructions here: http://flask.pocoo.org/snippets/65/

But some things aren't very clearly written.

So my structure is like this:

/<username>/webapps/flask/
----__init__.py
/<username>/webapps/flask/htdocs/
----index.py
----config.py
----/app/     (this is my flask application where i have views.py).
----/tmp/

My __init__.py:

class WebFactionMiddleware(object):
    def __init__(self, app):
        self.app = app
    def __call__(self, environ, start_response):
        environ['SCRIPT_NAME'] = '/app'
        return self.app(environ, start_response)

app.wsgi_app = WebFactionMiddleware(app.wsgi_app)

My index.py:

from flask import app as application

My httpd.conf:

WSGIPythonPath /home/<username>/webapps/flask/htdocs/
#If you do not specify the following directive the app *will* work but you will
#see index.py in the path of all URLs
WSGIScriptAlias /app /home/<username>/webapps/flask/htdocs/index.py

<Directory /home/<username>/webapps/flask/htdocs>
    AddHandler wsgi-script .py
    RewriteEngine on
    RewriteBase /app
    WSGIScriptReloading On
</Directory>

I installed from Control panel as "wsgi 3.4/Python2.7", but I had to install in SSH SQLAlchemy, flask-login, etc. using easy-install2.6 because easy-install2.7 doesn't exist.

Server error logs says:

 from flask import app as application
[Sun Nov 04 23:29:12 2012] [error] [client 127.0.0.1] ImportError: No module named flask

(I did restart apache2)

Paco
  • 4,520
  • 3
  • 29
  • 53
Dexter
  • 6,170
  • 18
  • 74
  • 101

2 Answers2

1

Well the error message clearly says that you don't have Flask installed. If you created application in webfaction control panel as for Python 2.7 then you also need to install all the libs and Flask itself for Python 2.7. You saying that you installed everything with easy_instal2.6, so it means you installed everything for Python 2.6.

I would say firstly install all the libs and deps (flask too) for Python 2.7 and try again. Also I would suggest to start using virtualenv, cause it will help do not mess with the packages versions later (some short info on how deploy with virtualenv on webfaction http://manavgoel.net/blog/post/2012/7/Deploying-flask-website-on-webfaction).

Ignas Butėnas
  • 6,061
  • 5
  • 32
  • 47
  • Yes I agree with your analysis, but the trouble is. I installed wsgi3.4/Python2.7,but it has not shown up in my FTP libs. That is why easy_install2.7 doesn't work, somehow there is no Python2.7 when there should be. – Dexter Nov 05 '12 at 09:36
  • and what is your default Python? When you run python on server, what version it prints out? Maybe the default for you is 2.7 and that's why there is no easy_install with the specific version? – Ignas Butėnas Nov 05 '12 at 11:24
  • ok on another forum I figured it out a bit. Apparently, I was to make a folder for python2.7 and then use easy_install-2.7, and it works. It doesn't work if you don't create that empty folder. How confusing... – Dexter Nov 06 '12 at 08:21
  • confusing, really... I would say - report that to webfaction, maybe they will fix it and it will save time for others in the future :) – Ignas Butėnas Nov 06 '12 at 09:15
  • Will do, sorry for the late best answer. THough I still haven't gotten a fully successful flask app installed without problems (now I'm running into blueprint problems). – Dexter Nov 22 '12 at 00:01
0

check out https://community.webfaction.com/questions/12718/installing-flask

ensure to follow the steps in the link accordingly. for step 2 there are many ways to go through. but i will like u to do this way.

a. copy that into a text editor first and change the APPNAME = "urflaskname" pls unix is case sensitive.

b. after that save the file as anyname.sh (unix script)

c. transfer to the server and run

chmod a+x anyname.sh

d. then now run this in the server to install flask and get you ready for the web

./anyname.sh

all is done.

You can also follow the steps directly but to ensure all righteousness try copying and editting only the APPNAME

Transformer
  • 3,642
  • 1
  • 22
  • 33