DEV Community

Cover image for How to use uWSGI with python3.6 in Ubuntu
Paolo Melchiorre
Paolo Melchiorre

Posted on • Edited on • Originally published at paulox.net

How to use uWSGI with python3.6 in Ubuntu

Step-by-step how-to to use uWSGI with python3.6 for Ubuntu 16.10+:

$ sudo apt-get install python3.6 python3.6-dev uwsgi uwsgi-src uuid-dev libcap-dev libpcre3-dev
$ cd ~
$ PYTHON=python3.6 uwsgi --build-plugin "/usr/src/uwsgi/plugins/python python36"
$ sudo mv python36_plugin.so /usr/lib/uwsgi/plugins/python36_plugin.so
$ sudo chmod 644 /usr/lib/uwsgi/plugins/python36_plugin.so
$ uwsgi --plugin python36 -s :0 # Ubuntu 16.10
...
Python version: 3.6.0b2 (default, Oct 11 2016, 05:27:10)  [GCC 6.2.0 20161005]
...
$ uwsgi --plugin python36 -s :0 # Ubuntu 17.04
...
Python version: 3.6.1 (default, Mar 22 2017, 06:17:05)  [GCC 6.3.0 20170321]
...
Enter fullscreen mode Exit fullscreen mode

Originally posted on www.paulox.net

Top comments (12)

Collapse
 
jorgii profile image
George Goranov

I have an issue with that solution. When I run multiple apps with uwsgin (configs in /etc/uwsgi/apps-available) the plugin option does not seem to work.

I put plugin=python35 to one and plugin=python36 to the other and at the end both try to run with python36. Only when I remove /usr/lib/uwsgi/plugins/python36_plugin.so then uwsgi runs python3.5

The weirder thing is that running uwsgi --plugin python36 -s :0 and uwsgi --plugin python35 -s :0 spawns it with the correct version of python.

Any idea what could cause it?

Collapse
 
jorgii profile image
George Goranov

Managed to solve my issue!

I have installed uwsgi package for ubuntu (16.10).
Afterwards I installed uwsgi-emperor where I copied my previous configs.

Another issue that I had was master=True in the apps .ini files. This should be False to be able to run multiple python versions.

Collapse
 
pauloxnet profile image
Paolo Melchiorre

Hi George and thanks to shared your solutions.

Collapse
 
karolyi profile image
László Károlyi

also install:

  • uuid-dev
  • libcap-dev
  • libpcre3-dev
Collapse
 
pauloxnet profile image
Paolo Melchiorre

Hi László this packages are not-direct dependencies from the packages I suggested to install ?

Collapse
 
karolyi profile image
László Károlyi

not really, at least not on my system, that is why I added them here. you can try it for yourself on a virtual machine with a fresh install.

Thread Thread
 
pauloxnet profile image
Paolo Melchiorre

You are right! I've updated the howto. Thanks for your suggestions.

Collapse
 
sindhujit profile image
sindhujit

I have tried a lot of things, even the Master = False, but I am getting "Internal Server Error" on my front-end. Uwsgi works with python2.7 , but is not working with 3.6.

Collapse
 
pauloxnet profile image
Paolo Melchiorre

This post is related to use python3.6 with old version of Ubuntu.
Have you tried the steps in above post and verified the result ?

Collapse
 
sindhujit profile image
sindhujit • Edited

Yes I have. This is a redhat rhel distro. Everything works with python2.7. It fails with 3.6. Is it because I have diff versions of python? However each has its own virtualenv. The uwsgi plugin does not seem to work with python3.6. I get unable to find python3.6 plugin when I try to build it

Thread Thread
 
pauloxnet profile image
Paolo Melchiorre

Sorry but I never tried this instructions with a Red Hat, as I reported this instructions are for Ubuntu.

Collapse
 
dertee profile image
DerTee

just tried to compile, got an error about a missing openssl include file and found out that i also had to:
sudo apt-get install libssl-dev