Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask, Nginx, uWSGI Python Application not found

I'm trying to setup NGINX, uWSGI and Flask. I'm currently getting,


uWSGI Error

Python application not found


I get some strange errors in my uwsgi error file, which you can find at the bottom of my post.

I'll get straight to it, this is on a fresh VPS running Ubuntu 13.04 64bit, these are the commands I ran.

  • sudo apt-get update
  • sudo apt-get install build-essential
  • sudo apt-get install python-dev
  • sudo apt-get install python-pip
  • sudo apt-get install nginx
  • sudo apt-get install uwsgi
  • sudo apt-get install uwsgi-plugin-python
  • sudo pip install virtualenv

I then created a virtual environment, activated it and ran pip install flask I then made a folder called app and place a file called hello.py inside the same folder

/project
    /app
        -hello.py
    /bin
    /include
    /lib
    /local

This is my NGINX file (the nginx error file is empty)

server {
    listen 80;

    server_name project.domain.net;

    location / {
        try_files $uri @app;
    }

    location @app {
        include uwsgi_params;
        uwsgi_pass unix:/tmp/uwsgi.sock;
    }

    location ~ /\. {
        deny all;
    }
}

This is my uWSGI ini file

[uwsgi]
chdir = /home/user/projects/python/flask/project
uid = www-data
gid = www-data
chmod-socket = 666
plugin = python
socket = /tmp/uwsgi.sock
module = run
callable = app
virtualenv = /home/user/projects/python/flask/project

This is my hello.py file

from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello_word():
    return "Hello World!"

if __name__ == "__main__":
    app.run()

This is my uWSGI error file https://p.kk7.me/sepukinulu.applescript it's quite long so I figured I would paste it in a pastebin-style website. I can edit my post to include it here if this is not ok.

Any help would be greatly appreciated!

like image 904
Andreas Avatar asked Oct 04 '22 02:10

Andreas


1 Answers

You are requesting a 'run' module while your script is 'hello', infact:

ImportError: No module named run

like image 66
roberto Avatar answered Oct 13 '22 01:10

roberto