web2py on Raspbian and Python 2 or 3?

207 views
Skip to first unread message

lucas

unread,
May 22, 2019, 5:43:38 PM5/22/19
to web2py-users
hello one and all,

yes, I have web2py 2.17.2 running on a raspberry pi model 3 b+, raspbian is its OS, as a server for my students to mess up.  on this "server", under nginx 1.10.3, web2py is currently using python 2.7.13.  but raspbian has both python 2 (2.17.13) and 3, specifically 3.5.3.  I read that the executable for web2py is python version specific, but I want to make sure I reading and understanding properly.

anyway, can I switch web2py to run python 3 as its core instead of the python 2, since raspbian has both python versions already running on it?  and specifically, what would it take to get web2py to use the python 3 that is already native on raspbian?

the reason is because the adafruit ads1115 analog-to-digital library only runs on python 3 and I'd like web2py to access the board directly.

thank you in advance and have a good day.  Lucas

Massimo Di Pierro

unread,
May 24, 2019, 4:12:47 AM5/24/19
to web2py-users
web2py runs on python 2 and python 3 but most of the apps are written for python 2. your existing apps will have to be modified. web2py does not care.

lucas

unread,
Jun 4, 2019, 9:04:48 PM6/4/19
to web...@googlegroups.com
so, what is the best way to direct web2py to use the python3 instead of the default python/python2.7?

i did change the symbolic link of /usr/bin/python to /usr/bin/python3.5, then rebooted, but didn't do the trick with web2py.

黄祥

unread,
Jun 4, 2019, 9:32:28 PM6/4/19
to web2py-users
dont mess with the /usr/bin/ by create the symbolic link, the safest way perhaps you can create a shell script
e.g.
start_web2py.sh
python3 /path_to_web2py/web2py.py

then start your web2py server with 
./start_web2py.sh

best regards,
stifan

lucas

unread,
Jun 7, 2019, 5:37:54 AM6/7/19
to web2py-users
i can not for the life of me figure out where to change to the python3.5 environment for web2py.  i tried changing the python symbolic link, and changed to python3.5 in multiple files under web2py main directory, uwsgi, etc., but i can not get web2py to boot straight into python3.5.  where is the secret spot.  i'm using nginx 1.10.3 and uwsgi 2.0.14 and the wsgihandler.py properly, etc.  lucas

黄祥

unread,
Jun 7, 2019, 6:02:22 AM6/7/19
to web2py-users
shell script not work ?
another way around perhaps can use conda 3 or miniconda 3, install it and it automatically add variable PATH on your bash file, reload it, then, the default of your python bash will refer to conda installed path

best regards,
stifan

lucas

unread,
Jun 7, 2019, 9:39:42 AM6/7/19
to web2py-users
well....  isn't python opened with either nginx (nginx.service) or uwsgi (emperor.uwsgi.service) with systemctl.  I've been trying to find that script to change the python to python3.5.  but I can't seem to find it under either of those two or under web2py.

Val K

unread,
Jun 7, 2019, 9:50:12 AM6/7/19
to web2py-users
Did you look at /etc/systemd/system

lucas

unread,
Jun 7, 2019, 3:00:14 PM6/7/19
to web2py-users
i haven't until you just mentioned it.  there is an emperor.uwsgi.service file.  its contents are:

[Unit]
Description = uWSGI Emperor
After = syslog.target

[Service]
ExecStart = /usr/local/bin/uwsgi --ini /etc/uwsgi/web2py.ini
RuntimeDirectory = uwsgi
Restart = always
KillSignal = SIGQUIT
Type = notify
StandardError = syslog
NotifyAccess = all

[Install]
WantedBy = multi-user.target

is there a way or option to ensure that it starts the /usr/bin/python3.5 environment in there somehow?

On Friday, June 7, 2019 at 9:50:12 AM UTC-4, Val K wrote:
Did you look at /etc/systemd/system

Dave S

unread,
Jun 7, 2019, 5:12:58 PM6/7/19
to web2py-users


On Friday, June 7, 2019 at 2:37:54 AM UTC-7, lucas wrote:
i can not for the life of me figure out where to change to the python3.5 environment for web2py.  i tried changing the python symbolic link, and changed to python3.5 in multiple files under web2py main directory, uwsgi, etc., but i can not get web2py to boot straight into python3.5.  where is the secret spot.  i'm using nginx 1.10.3 and uwsgi 2.0.14 and the wsgihandler.py properly, etc.  lucas

You may not be able to do it with a distro build of uwsgi.  a quick Google (tm) search found Stack Overflow articles, one of which pointed to
<URL:https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html#bonus-multiple-python-versions-for-the-same-uwsgi-binary>

/dps

Val K

unread,
Jun 7, 2019, 7:31:28 PM6/7/19
to web2py-users
uWSGI is very cool, but since you are on Raspbian maybe gunicorn is more suitable?

Donald McClymont

unread,
Jun 11, 2019, 5:18:04 PM6/11/19
to web2py-users
Why not just use the built in rocket server on a pi?  Seems far simpler and performance is always going to be fairly limited given the hardware you are running on?

Massimo Di Pierro

unread,
Jun 12, 2019, 11:13:29 PM6/12/19
to web2py-users
I agree. On a pi you do not have a lot of cores. I would stick with just rocket

lucas

unread,
Aug 21, 2019, 10:01:56 PM8/21/19
to web...@googlegroups.com
sorry for the long delay on this post.  I've been theme parking with the kids all summer.

ok, I've got rocket running on the pi under raspbian with python 3.5.  very well.

I placed:

/home/www-data/web2py/anyserver.py &

in /etc/rc.local so it will automatically start on boot and that's it.  interfacing through chromium browser is stardard web2py business as usual.

thanx in advance and have a great day, Lucas

Christian Varas

unread,
Aug 22, 2019, 2:56:37 AM8/22/19
to web...@googlegroups.com
I run web2py in a raspberry with Apache or nginx.
Then the auto start is automatically.

Cheers.


El jue., 22 de ago. de 2019 04:02, lucas <sjlu...@gmail.com> escribió:
sorry for the long delay on this post.  I've been theme parking with the kids all summer.

ok, I've got rocket running on the pi with python 3.5.  very well.

what's the best way to auto startup 

/home/www-data/web2py/anyserver.py &

on the pi?  when I manually type execute the above in a bash window, it starts fine and the server is accessible via the chromium browser.  when I try to put it in /etc/rc.local the command will not run when I reboot.  any suggestions on that latter point.

thanx in advance and have a great day, Lucas

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/20a52d68-50ea-4a86-98fb-a8f32ebf1f39%40googlegroups.com.

Donald McClymont

unread,
Aug 24, 2019, 7:28:40 AM8/24/19
to web2py-users
I just start it with systemd but there are various options to run scripts at startup - I did need to put some sort of instructions in to make sure Web2py starts after the network is up and running - having done this it did start fine.

Donald

Reply all
Reply to author
Forward
0 new messages