How to upgrade erpnext from python 3.5 to 3.8

Recently Frappe updated it’s dependencies so that you’ll get an error on update in case you’re using python < 3.7.

Here’s what I did to upgrade to python3.8 under Ubuntu (18.04 and 20.04). This is a more detailed version of my quick note on GitHub.

:bangbang: Remember to take a backup of your server first! :bangbang:

Install python and python-dev packages for 3.8:

sudo apt install python3.8 python3.8-dev

Switch to your bench directory:

cd /home/frappe/frappe-bench

Now you could, in theory, run bench migrate-env python3.8 and be done. But this produced an error for me, so I had to do everything manually instead. Let me know if bench migrate-env works for you!

Move your old python env folder to env-old. This way you make space for the new env while keeping a copy to restore in case something goes wrong.

mv env env-old

Create a new python environment with python3.8

virtualenv --python python3.8 env

In case the above command doesn’t work (I had problems on one machine) you can try this alternative:

python3.8 -m venv env

Upgrade pip to the newest version. The later commands will fail in case your pip version is too old.

env/bin/pip install -U pip

Now we can reinstall our apps and their dependencies. Here I only show frappe and erpnext. Please append all your custom apps to the command like this: -e apps/my-app

env/bin/pip install -e apps/frappe -e apps/erpnext

I like to run bench update at the end to see if everything worked:

bench update --reset

If everything went well you can delete your old env (optional, use with care):

rm -rf env-old
19 Likes