0

I am doing my project on linux server configuration and using ubuntu on amazon lighsail. i was having python2.7.5 and python 3 installed i changed it to python 3 by changing alias as my application is on python3.

My wsgi server is configured as below

#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/FlaskApp/")

from FlaskApp import app as application
application.secret_key = 'Add your secret key'

My config file is as below

<VirtualHost *:80>
    ServerName 52.24.125.53
    ServerAdmin abc@gmail.com
    WSGIScriptAlias / /var/www/FlaskApp/flaskapp.wsgi
    <Directory /var/www/FlaskApp/FlaskApp/>
        Order allow,deny
        Allow from all
    </Directory>
    Alias /static /var/www/FlaskApp/FlaskApp/static
    <Directory /var/www/FlaskApp/FlaskApp/static/>
        Order allow,deny
        Allow from all
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

As i try to access by ip address it shows internal error 500

Below is the error log

[Mon Sep 10 15:53:22.843424 2018] [wsgi:error] [pid 3620:tid 140263087400704] [client 103.211.114.174:27167]     from flask import Flask, render_template
[Mon Sep 10 15:53:22.843450 2018] [wsgi:error] [pid 3620:tid 140263087400704] [client 103.211.114.174:27167] ImportError: No module named 'flask'
[Mon Sep 10 15:53:23.421818 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] mod_wsgi (pid=3619): Target WSGI script '/var/www/FlaskApp/flaskapp.wsgi' cannot be loaded as Python module., referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.421875 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] mod_wsgi (pid=3619): Exception occurred processing WSGI script '/var/www/FlaskApp/flaskapp.wsgi'., referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.421968 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] Traceback (most recent call last):, referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.421991 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174]   File "/var/www/FlaskApp/flaskapp.wsgi", line 7, in <module>, referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.421995 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174]     from FlaskApp import app as application, referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.422001 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174]   File "/var/www/FlaskApp/FlaskApp/__init__.py", line 1, in <module>, referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.422004 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174]     from flask import Flask, render_template, referer: http://18.222.248.66/
[Mon Sep 10 15:53:23.422019 2018] [wsgi:error] [pid 3619:tid 140263194842880] [client 103.211.114.174:27174] ImportError: No module named 'flask', referer: http://18.222.248.66/

I have installed all modules on python3 and python2.7.5 package.but still its showing import error.I think its problem with wsgi.I am new to this please help to fix problem.

Andrew_Lvov
  • 4,621
  • 2
  • 25
  • 31
  • Look at http://terokarvinen.com/2016/deploy-flask-python3-on-apache2-ubuntu – Nic3500 Sep 10 '18 at 10:56
  • Possible duplicate of [Flask, mod\_wsgi, and Apache: ImportError](https://stackoverflow.com/questions/13329354/flask-mod-wsgi-and-apache-importerror) – Nic3500 Sep 10 '18 at 10:56
  • how to know which python version dependencies to be installed. .and how we remove duplicates. – user9609050 Sep 10 '18 at 11:26

1 Answers1

0

you need to check module name in your app

I think that you imported the module name "from flask import flask".

(or)

you need to install flask

pip install Flask
wailinux
  • 139
  • 4
  • my app is working fine in local server. .but its giving import error while using apache.I have installed flask.tried using even pip3 and pip. – user9609050 Sep 10 '18 at 11:06