Well, I already configured my Apache, MySql and Python. Installed the mod_wsgi and ran a example .wsgi "Hello World" application on my system. My Flask application is also running using Flask's webserver executing python myServer.py inside and outside my virtualenv that is also well configured (flask and mysql-python installed).
Now I'm trying to deploy my flask application and I'm getting the following error from the page:
Server error!
The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
If you think this is a server error, please contact the webmaster.
Error 500
I went to the Error Log from Apache and I got this:
[Mon Jul 14 19:27:50.692271 2014] [wsgi:error] [pid 56887] [remote ::1:0] mod_wsgi (pid=56887): Target WSGI script '/Applications/XAMPP/htdocs/nudgeAlong/wsgi/myServer.wsgi' cannot be loaded as Python module.
[Mon Jul 14 19:27:50.692387 2014] [wsgi:error] [pid 56887] [remote ::1:0] mod_wsgi (pid=56887): Exception occurred processing WSGI script '/Applications/XAMPP/htdocs/nudgeAlong/wsgi/myServer.wsgi'.
[Mon Jul 14 19:27:50.692411 2014] [wsgi:error] [pid 56887] [remote ::1:0] Traceback (most recent call last):
[Mon Jul 14 19:27:50.692438 2014] [wsgi:error] [pid 56887] [remote ::1:0] File "/Applications/XAMPP/htdocs/nudgeAlong/wsgi/myServer.wsgi", line 4, in <module>
[Mon Jul 14 19:27:50.692535 2014] [wsgi:error] [pid 56887] [remote ::1:0] from myServer import app as application
[Mon Jul 14 19:27:50.692553 2014] [wsgi:error] [pid 56887] [remote ::1:0] File "/Applications/xampp/xamppfiles/htdocs/nudgeAlong/myServer.py", line 2, in <module>
[Mon Jul 14 19:27:50.692633 2014] [wsgi:error] [pid 56887] [remote ::1:0] import MySQLdb
[Mon Jul 14 19:27:50.692658 2014] [wsgi:error] [pid 56887] [remote ::1:0] ImportError: No module named MySQLdb
My Wsgi application here:
import sys
activate_this = '/Applications/XAMPP/htdocs/nudgeAlong/venv/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
sys.path.append('/Applications/xampp/xamppfiles/htdocs/nudgeAlong/')
from myServer import app as application
My httpd.conf virtual host part is:
<VirtualHost *>
ServerName MeuServer
WSGIDaemonProcess myServer threads=5
WSGIScriptAlias /myapp /Applications/XAMPP/htdocs/nudgeAlong/wsgi/myServer.wsgi
<Directory /Applications/XAMPP/htdocs/nudgeAlong/wsgi>
WSGIProcessGroup myServer
WSGIApplicationGroup %{GLOBAL}
Require all granted
</Directory>
</VirtualHost>
My folders are structured like this:
__mainfolder
____myServer.py
____wsgi/
________myServer.wsgi
____venv/
Hope anyone can help. The curious thing about the situation is that the error is occuring in line 2 of my program, the import MySQLdb line, but before that I imported Flask and no error occured, so I'm probably getting the libraries from my system...
To finish, my Flask app if needed:
from flask import Flask, jsonify, render_template, request, make_response, request, current_app
import MySQLdb
from datetime import timedelta
app = Flask(__name__)
db_owen = MySQLdb.connect("localhost","root","","climote_trial")
@app.route('/get_json')
@crossdomain(origin='*')
def get_json():
results = []
c = db_owen.cursor()
c.execute("select date,message_log from trialresults")
jsonresult = c.fetchall()
for x in jsonresult:
dic = {'col1':str(x[0]),'col2':x[1] }
results.append(dic)
return jsonify({ 'results':results });
@app.route('/')
def index():
return render_template('number_1.html')
if __name__ == '__main__':
app.run(debug= True, port=53000)
pip freezewhen the virtualenv is active?