ImportError:没有名为flask_sqlalchemy的模块,referer:http:// localhost /

时间:2016-10-01 21:50:50

标签: python apache flask apache2 flask-sqlalchemy

我使用flask_sqlalchemy从python shell看起来一切都很好我的脚本工作正常也没问题但是apache2 / error.log给了我这个

[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/

我安装了模块我知道因为脚本工作并且没有抱怨任何模块丢失但不知怎的apache2确实我得到了500服务器错误我在flask_sqlalchemy之后开始收到服务器错误

修改

这是错误我知道我已经尝试了很多东西来修复它但没有去它说模块名称形式无法找到但这就是我自己创建的模块它工作正常但是因为我为python3安装了wsgi它开始发生了

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')

顺便说一句,我的form.py文件与应该执行它的app.py位于同一目录中

0 个答案:

没有答案