Getting Nginx + uWSGI + Pyramid working

86 views
Skip to first unread message

Darren Jones

unread,
Mar 1, 2018, 11:37:45 AM3/1/18
to pylons-discuss
Dear all.

I've written my first (worthwhile!) app using Pyramid, and want to deploy it to a raspberry pi.  I've got the pi up and running, and nginx working fine - it can serve a static page or even a simple (test, three line) wsgi app.  However, I am hitting a brick wall on getting the pyramid app up and running using uWSGI.  I've spent the last three days (solidly!) trying to get this up and running, and still I can't get it going.  I've tried loads, but my current issue appears to be that I can't get uWSGI to run the pyramid app from the command line - my current launch command is sudo uwsgi --plugin python3 -H /srv/venv production.ini --socket/srv/myapp/uwsgi.sock

When I run this, I just get [uWSGI] getting INI configuration from production.ini, and then back to the command line.

Yesterday, I got as far as sudo uwsgi --plugin python3 -H /srv/venv --paste config:/srv/myapp/gdpr_permissions/production.ini --socket /srv/myapp/uwsgi.sock which was giving me more output (what looks to be the uWSGI startup info), but then errors such as

pkg_resources.DistributionNotFound: the gdpr_permissions distribution was not found and is required by gdpr_permissions

I don't seem to be able to find an authoratitive tutorial on this - they either say 'simply enter uWSGI production.ini and away you go', or seem to be 5+ years out of date, and I'll get so far and then run aground again - many of the links given searching on this list for nginx uwsgi lead me to either dead links, things I've already tried, or impenetrably complex explanations that don't go into details relevant to pyramid apps.

If someone could point me in the right direction, it would be immensely helpful.  I don't -think- I'm a complete idiot (I'm happy doing sysadmin stuff, and have compiled from source back in the RH5 days,etc), but it seems everyone else must be able to just get this working without issues given the lack of discussion on the subject.  I'm at the point of giving up.

Thanks

Darren

Michael Merickel

unread,
Mar 1, 2018, 11:41:20 AM3/1/18
to Pylons
The DistributionNotFound error basically always means that your code is not installed into the virtualenv being used by uwsgi. In this case it's /srv/venv. You should ensure that you've run /srv/venv/bin/pip install appropriately.

- Michael

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to pylons-discuss@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/6e882888-2ab4-42d7-8502-6c89423104cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Merickel

unread,
Mar 1, 2018, 2:20:49 PM3/1/18
to Pylons
The easiest way to see if your code is installed properly is to make sure you are not in the folder with your code and then try to import it.

$ cd /
$ /srv/venv/bin/python
>>> import gdpr_permissions

If this doesn't work then it's not installed correctly either using `/srv/venv/bin/pip install -e <path/to/folder/with/setup.py>` or without the `-e` depending on your goals.

Further if you want to test that your ini file is pointing at your code properly then you can do that similarly.

$ cd /
$ /srv/venv/bin/python
>>> from pyramid.paster import get_app
>>> app = get_app('/srv/myapp/gdpr_permissions/production.ini')

This command is almost exactly what uwsgi is doing to load your code and it will fail with the same DistributionNotFound error you're seeing.

- Michael


To post to this group, send email to pylons-...@googlegroups.com.

Darren Jones

unread,
Mar 1, 2018, 3:10:18 PM3/1/18
to pylons-discuss
Michael - thanks a million!  That was what I needed (and another hour of work!) to get it up and running - just got it running now.  Now that I have it up and running I will be able to get it all working much more smoothly (I think something is awry with the current setup and permissions), but I have something to work from now.  Thanks again, your advice was invaluable! 

Darren
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.

Steve Piercy

unread,
Mar 1, 2018, 3:35:42 PM3/1/18
to pylons-...@googlegroups.com
Were there any things peculiar to the Raspberry Pi environment
to get it running? If so, it would a cool thing to blog about,
or add a recipie to Pyramid Community Cookbook under Deployment.

https://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/deployment/

--steve


On 3/1/18 at 12:10 PM, djay...@gmail.com (Darren Jones) pronounced:
>>>>from it, send an email to pylons-discus...@googlegroups.com <javascript:>.
>>>> To post to this group, send email to
>>>>pylons-...@googlegroups.com <javascript:>.
><https://groups.google.com/d/msgid/pylons-discuss/6e882888-2ab4-42d7-8502-6c89423104cf%
>40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>
>

------------------------
Steve Piercy, Eugene, OR

Darren Jones

unread,
Mar 3, 2018, 2:39:59 AM3/3/18
to pylons-discuss
Hi Steve

I think some of it is Pi (or raspbian) specific, but also I think it's something I'd like to do anyway, to provide a guide specific to running it on the Pi - could help people who are less experienced get up and running.

When I've got it all up and running nicely (with all the config done in files, and it auto-starting on boot, etc), I'm planning to do exactly that.... when!

Darren
Reply all
Reply to author
Forward
0 new messages