librelist archives

« back to archive

Deploying Flask UWSGI Nginx VirtualEnv - No luck

Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
James Willson
Date:
2012-06-30 @ 22:46
Hi,
This is my last resort to post here, but nobody seems to have experience 
dealing with this stack and for the life of my I cant get my head around 
it (I'm new to this Python Sysadmin stuff).
I get this error after running my deployment script: uWSGI Error: Python 
application not found
I really don't know how to diagnose this. The UWSGI log file 
var/log/uwsgi.log is empty so no clues there.
Any help or advice would be hugely appreciated, I would love to see my 
site online rather than these pesky errors!
James 		 	   		  

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
Juancarlo Añez
Date:
2012-06-30 @ 23:34
Show us some code, James.

What does the Python WSGI application declaration look like, and how is it
invoked from uWSGI?

-- Juancarlo

On Sat, Jun 30, 2012 at 6:16 PM, James Willson <james_willson@hotmail.com>wrote:

>  Hi,
>
> This is my last resort to post here, but nobody seems to have experience
> dealing with this stack and for the life of my I cant get my head around it
> (I'm new to this Python Sysadmin stuff).
>
> I get this error after running my deployment script: uWSGI Error: Python
> application not found
>
> I really don't know how to diagnose this. The UWSGI log file
> var/log/uwsgi.log is empty so no clues there.
>
> Any help or advice would be hugely appreciated, I would love to see my
> site online rath er than these pesky errors!
>
> James
>



-- 
Juancarlo *Añez*

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
James Willson
Date:
2012-07-01 @ 13:25
I've made progress, I think. I found another uwsgi log file that wasnt 
empty, this time I found that it said:
========================================================  File 
"/home/deploy/repo/app/__init__.py", line 1, in <module>    from flask 
import Flask, render_templateImportError: No module named flaskunable to 
load app 0 (mountpoint='') (callable not found or import error)
========================================================
My Nginx app-nginx.conf configuration looks like this:server {    listen
80;    server_name  xyz;
location / {        include uwsgi_params;        uwsgi_pass 
127.0.0.1:8001;        uwsgi_param SCRIPT_NAME "";    }
}
Finally my app.conf looks like this:
[program:app]directory=/home/deployuser=deploycommand=/opt/bin/uwsgi -H 
/home/deploy/venv -L -w app:app --socket 127.0.0.1:8001 --master 
--processes 1 --pidfile 
/tmp/app-uwsgi.pidstdout_logfile=/home/deploy/logs/uwsgi.logredirect_stderr=truestopsignal=INTautorestart=true
It looks like I can see the error, but again, I dont know why its 
happening. Is this enough information for someone to offer me some more 
help?
James
Date: Sat, 30 Jun 2012 19:04:05 -0430
From: juancarlo.anez@gmail.com
Subject: Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck
To: flask@librelist.com

Show us some code, James.
What does the Python WSGI application declaration look like, and how is it
invoked from uWSGI?

-- Juancarlo

On Sat, Jun 30, 2012 at 6:16 PM, James Willson <james_willson@hotmail.com> wrote:






Hi,
This is my last resort to post here, but nobody seems to have experience 
dealing with this stack and for the life of my I cant get my head around 
it (I'm new to this Python Sysadmin stuff).


I get this error after running my deployment script: uWSGI Error: Python 
application not found


I really don't know how to diagnose this. The UWSGI log file 
var/log/uwsgi.log is empty so no clues there.


Any help or advice would be hugely appreciated, I would love to see my 
site online rath
 er than these pesky errors!
James

 		 	   		  


-- 
Juancarlo Añez


 		 	   		  

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
Roberto De Ioris
Date:
2012-07-01 @ 13:33
Il giorno 01/lug/2012, alle ore 15:25, James Willson ha scritto:

> I've made progress, I think. I found another uwsgi log file that wasnt 
empty, this time I found that it said:
> 
> ========================================================
> 
>   File "/home/deploy/repo/app/__init__.py", line 1, in <module>
>     from flask import Flask, render_template
> ImportError: No module named flask
> unable to load app 0 (mountpoint='') (callable not found or import error)
> 
> ========================================================
> 
> My Nginx app-nginx.conf configuration looks like this:
> server {
>     listen       80;
>     server_name  xyz;
> 
> location / {
>         include uwsgi_params;
>         uwsgi_pass 127.0.0.1:8001;
>         uwsgi_param SCRIPT_NAME "";
>     }
> 
> }
> 
> Finally my app.conf looks like this:
> 
> [program:app]
> directory=/home/deploy
> user=deploy
> command=/opt/bin/uwsgi -H /home/deploy/venv -L -w app:app --socket 
127.0.0.1:8001 --master --processes 1 --pidfile /tmp/app-uwsgi.pid
> stdout_logfile=/home/deploy/logs/uwsgi.log
> redirect_stderr=true
> stopsignal=INT
> autorestart=true
> 
> It looks like I can see the error, but again, I dont know why its 
happening. Is this enough information for someone to offer me some more 
help?
> 
> 

First of all, remove supervisor  (you can re-add it later if you need it).

Just run uWSGI from the commandline to see the logs on your terminal.

The nginx config is good.

Simply run uwsgi from the shell:

/opt/bin/uwsgi --virtualenv /home/deploy/venv --socket  127.0.0.1:8001 
--chdir /home/deploy --module app:app

(use full options name, at least they will have a meaning ;)

from your option it looks like a file named app.py is under  /home/deploy, right ?

Report the full uWSGI output, if it does not still work

--
Roberto De Ioris
http://unbit.it
JID: roberto@jabber.unbit.it

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
Juancarlo Añez
Date:
2012-07-03 @ 14:20
Does your application run with this?

...

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


-- JA

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
James Willson
Date:
2012-07-01 @ 18:47
Thank you for the help. Running from the command line produces the same 
result as with running through supervisor (i get the same message via the 
browser):
=============================================================

root@li453-78:~# /opt/bin/uwsgi --virtualenv /home/deploy/venv --socket 
127.0.0.1:8001 --chdir /home/deploy --module app:app*** Starting uWSGI 1.2
(32bit) on [Sun Jul  1 14:39:53 2012] ***compiled with version: 4.4.5 on 
30 June 2012 15:15:31detected number of CPU cores: 4current working 
directory: /rootdetected binary path: /opt/bin/uwsgiuWSGI running as root,
you can use --uid/--gid/--chroot options*** WARNING: you are running uWSGI
as root !!! (use the --uid flag) ****** WARNING: you are running uWSGI 
without its master process manager ***your memory page size is 4096 
bytesdetected max file descriptor number: 1024lock engine: pthread robust 
mutexesuwsgi socket 0 bound to TCP address 127.0.0.1:8001 fd 3Python 
version: 2.7.3 (default, Jun 30 2012, 15:14:01)  [GCC 4.4.5]Set PythonHome
to /home/deploy/venv*** Python threads support is disabled. You can enable
it with --enable-threads ***Python main interpreter initialized at 
0x8efa3a8your server socket listen backlog is limited to 100 
connections*** Operational MODE: single process ***Traceback (most recent 
call last):  File "/home/deploy/repo/app/__init__.py", line 1, in <module>
from flask import Flask, render_templateImportError: No module named 
flaskunable to load app 0 (mountpoint='') (callable not found or import 
error)*** no app loaded. going in full dynamic mode ****** uWSGI is 
running in multiple interpreter mode ***spawned uWSGI worker 1 (and the 
only) (pid: 3709, cores: 1)*** Starting uWSGI 1.2 (32bit) on [Sun Jul  1 
14:39:53 2012] ***compiled with version: 4.4.5 on 30 June 2012 
15:15:31detected number of CPU cores: 4current working directory: 
/rootdetected binary path: /opt/bin/uwsgiuWSGI running as root, you can 
use --uid/--gid/--chroot options*** WARNING: you are running uWSGI as root
!!! (use the --uid flag) ****** WARNING: you are running uWSGI without its
master process manager ***your memory page size is 4096 bytesdetected max 
file descriptor number: 1024lock engine: pthread robust mutexesuwsgi 
socket 0 bound to TCP address 127.0.0.1:8001 fd 3Python version: 2.7.3 
(default, Jun 30 2012, 15:14:01)  [GCC 4.4.5]Set PythonHome to 
/home/deploy/venv*** Python threads support is disabled. You can enable it
with --enable-threads ***Python main interpreter initialized at 
0x8efa3a8your server socket listen backlog is limited to 100 
connections*** Operational MODE: single process ***Traceback (most recent 
call last):  File "/home/deploy/repo/app/__init__.py", line 1, in <module>
from flask import Flask, render_templateImportError: No module named 
flaskunable to load app 0 (mountpoint='') (callable not found or import 
error)*** no app loaded. going in full dynamic mode ****** uWSGI is 
running in multiple interpreter mode ***spawned uWSGI worker 1 (and the 
only) (pid: 3709, cores: 1)
=============================================================
My structure under /home/deploy is as follows:deploy (linked 
folder)logspublic_htmlrepovenv
My app is in the following folder:/home/deploy/repo/app 
There is no "app.py" on my server or code, I dont think there ever was.
I hope this is enough information to help build up a picture, is there is 
anything else I can do to help understand whats going wrong please tell 
me.
James
> Date: Sun, 1 Jul 2012 15:33:02 +0200
> From: roberto@unbit.it
> Subject: Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck
> To: flask@librelist.com
> 
> 
> Il giorno 01/lug/2012, alle ore 15:25, James Willson ha scritto:
> 
> > I've made progress, I think. I found another uwsgi log file that wasnt
empty, this time I found that it said:
> > 
> > ========================================================
> > 
> >   File "/home/deploy/repo/app/__init__.py", line 1, in <module>
> >     from flask import Flask, render_template
> > ImportError: No module named flask
> > unable to load app 0 (mountpoint='') (callable not found or import error)
> > 
> > ========================================================
> > 
> > My Nginx app-nginx.conf configuration looks like this:
> > server {
> >     listen       80;
> >     server_name  xyz;
> > 
> > location / {
> >         include uwsgi_params;
> >         uwsgi_pass 127.0.0.1:8001;
> >         uwsgi_param SCRIPT_NAME "";
> >     }
> > 
> > }
> > 
> > Finally my app.conf looks like this:
> > 
> > [program:app]
> > directory=/home/deploy
> > user=deploy
> > command=/opt/bin/uwsgi -H /home/deploy/venv -L -w app:app --socket 
127.0.0.1:8001 --master --processes 1 --pidfile /tmp/app-uwsgi.pid
> > stdout_logfile=/home/deploy/logs/uwsgi.log
> > redirect_stderr=true
> > stopsignal=INT
> > autorestart=true
> > 
> > It looks like I can see the error, but again, I dont know why its 
happening. Is this enough information for someone to offer me some more 
help?
> > 
> > 
> 
> First of all, remove supervisor  (you can re-add it later if you need it).
> 
> Just run uWSGI from the commandline to see the logs on your terminal.
> 
> The nginx config is good.
> 
> Simply run uwsgi from the shell:
> 
> /opt/bin/uwsgi --virtualenv /home/deploy/venv --socket  127.0.0.1:8001 
--chdir /home/deploy --module app:app
> 
> (use full options name, at least they will have a meaning ;)
> 
> from your option it looks like a file named app.py is under  
/home/deploy, right ?
> 
> Report the full uWSGI output, if it does not still work
> 
> --
> Roberto De Ioris
> http://unbit.it
> JID: roberto@jabber.unbit.it
> 
 		 	   		  

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
Lars Hansson
Date:
2012-07-03 @ 04:49
You chdir to /home/deploy but your app is in /home/deply/repo/app so
telling uwsgi to use app:app will not work.
Chdir to /home/deploy/repo/app should make it work.

Cheers,
Lars

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
Lars Hansson
Date:
2012-07-03 @ 04:53
Also, do you have Flask installed in venv? It looks like it isn't.
Activate it and do "pip freeze -l" and check the output.

Cheers,
lars

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
Karsten Hoffrath
Date:
2012-07-02 @ 07:32
Hi,

did you copy and paste the output? It looks like your PythonHome path is invalid:

> Set PythonHome to /h ome/deploy/venv


Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
James Willson
Date:
2012-07-03 @ 14:03
I get the same error as before, both in shell and on my site. If anyone is
willing to help directly on my server I would be happy to pay for their 
time via paypal, its slowing down development at the moment and its 
frustrating.

> Date: Tue, 3 Jul 2012 09:42:53 +0200
> From: maillists@khoffrath.de
> Subject: Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck
> To: flask@librelist.com
> 
> Didn't catch the second line. Can you try to activate the venv in a 
shell, start python
> and import the app? Does this throw any errors?
> 
> Am 02.07.2012 10:06, schrieb James Willson:
> > Thank your for the reply. I did copy and paste the output, however, in
a lower line it
> > does say it correctly without the sapce so I dont know what happened 
there, but I'm not
> > sure if it is the root of the problem:
> > 
> > *"Set PythonHome to /home/deploy/venv"*
> > 
> > 
> > 
> >> Date: Mon, 2 Jul 2012 09:32:03 +0200
> >> From: maillists@khoffrath.de
> >> Subject: Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck
> >> To: flask@librelist.com
> >>
> >> Hi,
> >>
> >> did you copy and paste the output? It looks like your PythonHome path
is invalid:
> >>
> >> > Set PythonHome to /h ome/deploy/venv
> >>
> >>
> >>
> 
 		 	   		  

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
Karsten Hoffrath
Date:
2012-07-03 @ 20:05
Have you tried Lars suggestions:

> Also, do you have Flask installed in venv? It looks like it isn't.
> Activate it and do "pip freeze -l" and check the output.

The output of pip freeze -l should at least list Flask, Jinja2 and Werkzeug.


On 03.07.2012 16:03, James Willson wrote:
> I get the same error as before, both in shell and on my site. If anyone
> is willing to help directly on my server I would be happy to pay for
> their time via paypal, its slowing down development at the moment and
> its frustrating.
> 
>> Date: Tue, 3 Jul 2012 09:42:53 +0200
>> From: maillists@khoffrath.de
>> Subject: Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck
>> To: flask@librelist.com
>>
>> Didn't catch the second line. Can you try to activate the venv in a
> shell, start python
>> and import the app? Does this throw any errors?
>>
>> Am 02.07.2012 10:06, schrieb James Willson:
>> > Thank your for the reply. I did copy and paste the output, however,
> in a lower line it
>> > does say it correctly without the sapce so I dont know what happened
> there, but I'm not
>> > sure if it is the root of the problem:
>> >
>> > *"Set PythonHome to /ho me/deploy/venv"*
>> >
>> >
>> >
>> >> Date: Mon, 2 Jul 2012 09:32:03 +0200
>> >> From: maillists@khoffrath.de
>> >> Subject: Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck
>> >> To: flask@librelist.com
>> >>
>> >> Hi,
>> >>
>> >> did you copy and paste the output? It looks like your PythonHome
> path is invalid:
>> >>
>> >> > Set PythonHome to /h ome/deploy/venv
>> >>
>> >>
>> >>
>>

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
Glen Zangirolami
Date:
2012-07-03 @ 20:50
James,

What is the uWSGI command you are running? What parameters are you passing to it?
If you run python <flaskapp> do you get errors? Can you paste those errors here?

I have my stuff setup using supervisor, uWSGI, Nginx and virtualenvs. I 
can help but I need more info.

Glen 


On Tuesday, July 3, 2012 at 3:05 PM, Karsten Hoffrath wrote:

> Have you tried Lars suggestions:
> 
> > Also, do you have Flask installed in venv? It looks like it isn't.
> > Activate it and do "pip freeze -l" and check the output.
> > 
> 
> 
> The output of pip freeze -l should at least list Flask, Jinja2 and Werkzeug.
> 
> 
> On 03.07.2012 16:03, James Willson wrote:
> > I get the same error as before, both in shell and on my site. If anyone
> > is willing to help directly on my server I would be happy to pay for
> > their time via paypal, its slowing down development at the moment and
> > its frustrating.
> > 
> > > Date: Tue, 3 Jul 2012 09:42:53 +0200
> > > From: maillists@khoffrath.de (mailto:maillists@khoffrath.de)
> > > Subject: Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck
> > > To: flask@librelist.com (mailto:flask@librelist.com)
> > > 
> > > Didn't catch the second line. Can you try to activate the venv in a
> > shell, start python
> > > and import the app? Does this throw any errors?
> > > 
> > > Am 02.07.2012 10:06, schrieb James Willson:
> > > > Thank your for the reply. I did copy and paste the output, however,
> > > 
> > > 
> > 
> > in a lower line it
> > > > does say it correctly without the sapce so I dont know what happened
> > > 
> > 
> > there, but I'm not
> > > > sure if it is the root of the problem:
> > > > 
> > > > *"Set PythonHome to /ho me/deploy/venv"*
> > > > 
> > > > 
> > > > 
> > > > > Date: Mon, 2 Jul 2012 09:32:03 +0200
> > > > > From: maillists@khoffrath.de (mailto:maillists@khoffrath.de)
> > > > > Subject: Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck
> > > > > To: flask@librelist.com (mailto:flask@librelist.com)
> > > > > 
> > > > > Hi,
> > > > > 
> > > > > did you copy and paste the output? It looks like your PythonHome
> > path is invalid:
> > > > > 
> > > > > > Set PythonHome to /h ome/deploy/venv 

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
James Willson
Date:
2012-07-02 @ 08:06
Thank your for the reply. I did copy and paste the output, however, in a 
lower line it does say it correctly without the sapce so I dont know what 
happened there, but I'm not sure if it is the root of the problem:
"Set PythonHome to
/home/deploy/venv"

> Date: Mon, 2 Jul 2012 09:32:03 +0200
> From: maillists@khoffrath.de
> Subject: Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck
> To: flask@librelist.com
> 
> Hi,
> 
> did you copy and paste the output? It looks like your PythonHome path is
invalid:
> 
> > Set PythonHome to /h ome/deploy/venv
> 
> 
> 
 		 	   		  

Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck

From:
Karsten Hoffrath
Date:
2012-07-03 @ 07:42
Didn't catch the second line. Can you try to activate the venv in a shell,
start python
and import the app? Does this throw any errors?

Am 02.07.2012 10:06, schrieb James Willson:
> Thank your for the reply. I did copy and paste the output, however, in a
lower line it
> does say it correctly without the sapce so I dont know what happened 
there, but I'm not
> sure if it is the root of the problem:
> 
> *"Set PythonHome to /home/deploy/venv"*
> 
> 
> 
>> Date: Mon, 2 Jul 2012 09:32:03 +0200
>> From: maillists@khoffrath.de
>> Subject: Re: [flask] Deploying Flask UWSGI Nginx VirtualEnv - No luck
>> To: flask@librelist.com
>>
>> Hi,
>>
>> did you copy and paste the output? It looks like your PythonHome path 
is invalid:
>>
>> > Set PythonHome to /h ome/deploy/venv
>>
>>
>>