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

How to use uWSGI with python3.6 in Ubuntu

pauloxnet profile image Paolo Melchiorre Updated on ・1 min read

PauLoX's Howto (6 Part Series)

1) How to use uWSGI with python3.6 in Ubuntu 2) Upgrading PostgreSQL from 9.5 to 9.6 on Ubuntu 17.04 3 ... 4 3) How to use uWSGI Avahi plugin in Ubuntu 4) Upgrading PostgreSQL from 9.6 to 10.0 on Ubuntu 18.04 5) Upgrading PostgreSQL from version 10 to 11 on Ubuntu 19.04 (Disco Dingo) 6) Upgrading PostgreSQL from version 11 to 12 on Ubuntu 20.04 (Focal Fossa)

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]
...

Originally posted on www.paulox.net

PauLoX's Howto (6 Part Series)

1) How to use uWSGI with python3.6 in Ubuntu 2) Upgrading PostgreSQL from 9.5 to 9.6 on Ubuntu 17.04 3 ... 4 3) How to use uWSGI Avahi plugin in Ubuntu 4) Upgrading PostgreSQL from 9.6 to 10.0 on Ubuntu 18.04 5) Upgrading PostgreSQL from version 10 to 11 on Ubuntu 19.04 (Disco Dingo) 6) Upgrading PostgreSQL from version 11 to 12 on Ubuntu 20.04 (Focal Fossa)

Posted on Apr 4 '17 by:

pauloxnet profile

Paolo Melchiorre

@pauloxnet

🐍 Python developer 🦄 Django contributor ‍🗣️ Conference speaker 🏡 Remote worker 🐧 GNU/Linux user 👨‍💻 Free Software advocate

Discussion

markdown guide
 

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?

 

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.

 

Hi George and thanks to shared your solutions.

 

also install:

  • uuid-dev
  • libcap-dev
  • libpcre3-dev
 

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

 

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.

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

 

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.

 

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 ?

 

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

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

 

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