WebFaction
Community site: login faq

I tried to set up Flask on my server by following this guide: https://community.webfaction.com/questions/12718/installing-flask/12719

However, when I try to access the site it throws an internal server error. I checked the error log file and found:

[Wed Apr 22 15:17:00 2015] [error] [client 127.0.0.1] mod_wsgi (pid=90831): Target WSGI script '/home/rhayes777/webapps/app/wsgi.py' cannot be loaded as Python module.
[Wed Apr 22 15:17:00 2015] [error] [client 127.0.0.1] mod_wsgi (pid=90831): Exception occurred processing WSGI script '/home/rhayes777/webapps/app/wsgi.py'.
[Wed Apr 22 15:17:00 2015] [error] [client 127.0.0.1] Traceback (most recent call last):
[Wed Apr 22 15:17:00 2015] [error] [client 127.0.0.1]   File "/home/rhayes777/webapps/app/wsgi.py", line 3, in <module>
[Wed Apr 22 15:17:00 2015] [error] [client 127.0.0.1]     from app import app as application
[Wed Apr 22 15:17:00 2015] [error] [client 127.0.0.1]   File "/home/rhayes777/webapps/app/app/__init__.py", line 1, in <module>
[Wed Apr 22 15:17:00 2015] [error] [client 127.0.0.1]     from flask import Flask
[Wed Apr 22 15:17:00 2015] [error] [client 127.0.0.1] ImportError: No module named 'flask'

Any ideas?

Thanks

asked 22 Apr '15, 15:34

richardhayes
13115
accept rate: 0%

edited 22 Apr '15, 16:24


The problem is that you've installed Flask (and its dependencies) as Python 2.7 modules, but your app is being served from mod_wsgi built with Python 3.4.

Simply changing the Python search path may have some unexpected results, since you're using modules that are built for a different version of Python.

My recommendation is that you either:

  • Re-install your modules using Python 3.4, or...
  • Re-create your mod_wsgi app, using the Python 2.7 variant of the app.
permanent link

answered 22 Apr '15, 19:07

seanf
12.2k41836
accept rate: 37%

I managed to solve it

In webapps/{app name}/apache2/conf/httpd.conf I changed the line:

WSGIDaemonProcess app processes=5 python-path=/home/rhayes777/webapps/app/lib/python3.4 threads=1

to:

WSGIDaemonProcess app processes=5 python-path=/home/rhayes777/lib/python2.7 threads=1

Such that it now points at the folder in which flask was installed

permanent link

answered 22 Apr '15, 17:44

richardhayes
13115
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×44

question asked: 22 Apr '15, 15:34

question was seen: 13,217 times

last updated: 22 Apr '15, 19:07

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM