Can "production" versions of ERPNext v10 be upgraded to python 3?

I have a v10 ERPNext production server on Ubuntu 16.04 that I would like to update to python3.

  • Is this even possible?

  • If so, can someone pass along the steps to get there?

I have done a few searches through the forum and there seems to be some question about the validity of python3 on v10 servers. It was enough to make me ask this these questions and hope that one of the developers can address this for me (and the rest of the community).

Thanks in advance.

BKM

EDIT - Ultimately the answer is to keep python 2.7 and install python 3 just to support security certificates. Thanks to @tmatteson for the advice here.

2 Likes

I would not. I know you’ve got a scenario where you need to support old versions, so this may be a case where the medicine is as risk-prone as the sickness:
pypy’s version of python 2.7 is expected to be supported for years into the future
That means:
V10 of frappe/ERPNext will be secure and up to 7x faster
Some packages, including wkhtml2pdf and pycups are unlikely to work out of the box. I haven’t dug into this, but the pycups reasoning is easier to understand on its face: it’s a very thin python wrapper over the C cups library. That’s the scenario pypy calls out is problematic.
wkhtml2pdf is just a touchy piece of software

Interesting…

What about installing python 3 (in addition to the old 2.7) so that future Let’s Encrypt installations will work?

It is the long term support of the security certificates that I am most worried about.

BKM

The analysis of someone who tried to make py3 work with v10 was that it would be easier to deal with the pain of moving to v11 rather than try to backport things from v11 to make py3 work in v10 for their particular implementation. As always, YMMV.

1 Like

Also installing python3 on your server is not a big deal; it is not uncommon to have multiples installed. If all you want certbot to run correctly, this is the way to go.
Linux distros are beginning to not bundle python2 and starting to use python 3 as system python.

1 Like

Thanks Tyler!

I will start a different investigation now into how I can run the python3 certbot without using the bench commands (since the bench will still be a python 2.7 package).

BKM

You can set up certbot outside of frappe and it will work just fine

2 Likes

Definitely.

@bkm - I’ve always worked with CertBot and Let’s Encrypt outside of bench. Currently I’m creating and renewing certificates with a set of scripts and Docker containers. It’s easily done without Docker though (I just don’t like installing software on my servers that’s only needed occasionally).

Reach out to me if you need more info; I’ve got extensive documentation on creating certs for not just ERPNext, but for general-purpose websites.

Hey @brian_pond do you have a way to force the certbot to use python 3.x ?

That would be helpful right now. I want to keep the python 2.7 running the bench and just about everything else in my v10 sites, but want to specifically make Lets Encrypt use python 3.x for the certificate generator. I think the current Certbot just uses “python” to run its stuff but that is also what v10 does and it is already made as an alias so that v10 works properly. When Certbot uses the same alias it defaults to python 2.7

That is where I am stuck right now.

BKM

Off the cuff:

  1. Create a new, Python 3.x virtual environment.
    $ python3 -m venv my_new_env
  2. Enable this environment
    $ source my_new_env/bin/activate
  3. Install Certbot. I’ve never done it this way, but I think ‘certbot-auto’ is the way to go.
  4. Run your Certbot scripts.

Because you’re installing it in a Python3 virtual environment, it will use that Python3 by default. (it’s actually just some trickery with PATHs. But it’s good trickery)

Hopefully this helps. I’ve been using Docker, so that my Certbot is 100% isolated; doesn’t matter what Python(s) I have on my host that way. But Docker is complicated, and I don’t want to lead you down that path lightly.

As Ubuntu seems to be the most popular distro for ERPNext, I though I would leave this here as an extension to the discussion.

1 Like