Bench Environment - Python Etc


I have been a little messed up with the Bench Environment and the Python versions. I keep getting messages about Python 3.5 or Python 2.7 getting deprecated. So, can somebody that’s knowledgeable about these things, please help out and document and following:

  1. What version of Python should the bench environment be on? python3, python3.5, python3.6, python3.8?
  2. What are the prerequisites to be able to migrate the bench environment to the recommended Python version? Does the underlying Ubuntu supported on 16.x or does it have to be 18.x?
  3. What are the commands to successfully migrate the bench environment to the new version of Python? Does a new bench have to be created?

I lost two instances in the last few days. One was a ver 13 environment and the other a ver 12 environment. Both I think were on Ubuntu 16.x. Luckily both were non-Production environments, but I shall have to migrate my clients production environments very soon and I can’t afford to lose those instances.



  1. Use Python 3.6+
    It is necessary considering the use of f-strings in v13 code.

  2. Ubuntu 16.04 LTS has reached EOL as of Apr 2021. You should migrate to Ubuntu 20.04 LTS.

But no, it doesn’t have to be a newer version of Ubuntu. You can manually install newer versions of Python on Ubuntu 16/18.

  1. Once a newer Python is installed, you can just execute:
bench migrate-env [python executable]
  1. You don’t really lose instances. You can mess them up. But they can be recovered.

Hi Sagar,

Thank you for responding.

I had tried a whole bunch of things yesterday on this server and got into all kinds of trouble. So, I am trying again today to see if I can recover this test instance.

I first installed Python 3.8 using this link:

Then I tried bench migrate-env python3.8 from the frappe-bench folder and I am getting this error:

bench migrate-env python3.8Traceback (most recent call last):
File “/usr/local/bin/bench”, line 6, in
from pkg_resources import load_entry_point
File “/usr/lib/python3/dist-packages/pkg_resources/”, line 2928, in
def _initialize_master_working_set():
File “/usr/lib/python3/dist-packages/pkg_resources/”, line 2913, in _call_aside
f(*args, **kwargs)
File “/usr/lib/python3/dist-packages/pkg_resources/”, line 2940, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File “/usr/lib/python3/dist-packages/pkg_resources/”, line 635, in _build_master
File “/usr/lib/python3/dist-packages/pkg_resources/”, line 943, in require
needed = self.resolve(parse_requirements(requirements))
File “/usr/lib/python3/dist-packages/pkg_resources/”, line 829, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The ‘bench’ distribution was not found and is required by the application

Any thoughts/solutions?



Your installation of Bench CLI is probably messed up. This may help: