2

Im using flask_sqlalchemy everything looks good from python shell and my script works ok too no problem there but apache2/error.log gives me this

[Sat Oct 01 21:37:39.222205 2016] [mpm_event:notice] [pid 9722:tid 140236156835712] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Sat Oct 01 21:37:39.222234 2016] [core:notice] [pid 9722:tid 140236156835712] AH00094: Command line: '/usr/sbin/apache2'
[Sat Oct 01 21:37:45.141310 2016] [wsgi:error] [pid 9725:tid 140235983812352] [client 174.58.31.189:39274] mod_wsgi (pid=9725): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://localhost/
[Sat Oct 01 21:37:45.141418 2016] [wsgi:error] [pid 9725:tid 140235983812352] [client 174.58.31.189:39274] mod_wsgi (pid=9725): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://localhost/
[Sat Oct 01 21:37:45.141488 2016] [wsgi:error] [pid 9725:tid 140235983812352] [client 174.58.31.189:39274] Traceback (most recent call last):, referer: http://localhost/
[Sat Oct 01 21:37:45.141551 2016] [wsgi:error] [pid 9725:tid 140235983812352] [client 174.58.31.189:39274]   File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://localhost/
[Sat Oct 01 21:37:45.141710 2016] [wsgi:error] [pid 9725:tid 140235983812352] [client 174.58.31.189:39274]     from FlaskApp import app as application, referer: http://localhost/
[Sat Oct 01 21:37:45.141754 2016] [wsgi:error] [pid 9725:tid 140235983812352] [client 174.58.31.189:39274]   File "/var/www/FlaskApp/FlaskApp/__init__.py", line 2, in <module>, referer: http://localhost/
[Sat Oct 01 21:37:45.141883 2016] [wsgi:error] [pid 9725:tid 140235983812352] [client 174.58.31.189:39274]     from flask_sqlalchemy import SQLAlchemy, referer: http://localhost/
[Sat Oct 01 21:37:45.141967 2016] [wsgi:error] [pid 9725:tid 140235983812352] [client 174.58.31.189:39274] ImportError: No module named flask_sqlalchemy, referer: http://localhost/

i have the module installed i know because the script works and doesnt complain about any module missing but somehow apache2 does im getting the 500 server error i started getting server error after flask_sqlalchemy

EDIT:

this is the error i get know i have try a lot of things to fix it but no go it says that module name form cannot be found but thats a module i created myself it was working fine but since i installed wsgi for python3 it started happening

tail /var/log/apache2/error.log
[Sun Oct 02 21:03:38.594947 2016] [mpm_event:notice] [pid 29438:tid 139888375388032] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations
[Sun Oct 02 21:03:38.594997 2016] [core:notice] [pid 29438:tid 139888375388032] AH00094: Command line: '/usr/sbin/apache2'
[Sun Oct 02 21:03:44.952537 2016] [wsgi:error] [pid 29441:tid 139888158570240] [client 174.58.31.189:40546] mod_wsgi (pid=29441): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://localhost/
[Sun Oct 02 21:03:44.952791 2016] [wsgi:error] [pid 29441:tid 139888158570240] [client 174.58.31.189:40546] mod_wsgi (pid=29441): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://45.55.236.208/
[Sun Oct 02 21:03:44.953945 2016] [wsgi:error] [pid 29441:tid 139888158570240] [client 174.58.31.189:40546] Traceback (most recent call last):, referer: http://localhost/
[Sun Oct 02 21:03:44.954113 2016] [wsgi:error] [pid 29441:tid 139888158570240] [client 174.58.31.189:40546]   File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://localhost/
[Sun Oct 02 21:03:44.954148 2016] [wsgi:error] [pid 29441:tid 139888158570240] [client 174.58.31.189:40546]     from FlaskApp import app as application, referer: http://localhost/
[Sun Oct 02 21:03:44.954212 2016] [wsgi:error] [pid 29441:tid 139888158570240] [client 174.58.31.189:40546]   File "/var/www/FlaskApp/FlaskApp/__init__.py", line 3, in <module>, referer: http://localhost/
[Sun Oct 02 21:03:44.954239 2016] [wsgi:error] [pid 29441:tid 139888158570240] [client 174.58.31.189:40546]     from form import LoginForm, referer: http://localhost/
[Sun Oct 02 21:03:44.954361 2016] [wsgi:error] [pid 29441:tid 139888158570240] [client 174.58.31.189:40546] ImportError: No module named 'form', referer: http://localhost/

form.py

from wtforms import Form,StringField, PasswordField, TextField, BooleanField, SubmitField, validators

class LoginForm(Form):  

    username_signin = StringField('SigninU', [validators.Required('please enter name')])
    password_signin = PasswordField('signinP', [validators.Required('need password')])
    submit_signin = SubmitField('Signin')

by the way my form.py file is in the same directory as the app.py that is supposed to execute it

quechon
  • 99
  • 3
  • 10
  • Maybe you have installed two Pythons and Apache (or rather `mod_wsgi`) use different Python version which has no installed flask_sqlalchemy. – furas Oct 01 '16 at 21:53
  • As far as i know im using python3 as default i ve running python3 before i installed flask_sqlalchemy – quechon Oct 01 '16 at 22:02
  • In your log is `Python/2.7.12` so `Apache/mod_wsgi` doesn't use Python 3 – furas Oct 01 '16 at 22:03
  • Oooh i see do you know a easy way to make wsgi point to python3 thanks – quechon Oct 01 '16 at 22:15
  • I don't use Apache but it seems you have to install mod_wsgi for Python 3 - http://stackoverflow.com/questions/19344252/how-to-install-configure-mod-wsgi-for-py3 – furas Oct 01 '16 at 22:31
  • Just edited my post got a new problem cant solve it i have try everything in my power – quechon Oct 02 '16 at 21:32
  • It seems it can't find `form.py` file. Maybe `mod_wsgi` execute `app.py` from different folder so it can't find `form.py`. See flask doc and [mod_wsgi](http://flask.pocoo.org/docs/0.11/deploying/mod_wsgi/). they use `sys.path.insert(0, '/path/to/the/application')` – furas Oct 02 '16 at 23:25
  • 1
    Thanks i solved it already – quechon Oct 02 '16 at 23:26

0 Answers0