ERPNext V11, Python 3 or 2.7

Hi, I’m planing to use ERPNext V11 in production server.

Which python is more stable for V11?

Python 2.7 or Python 3


Python 3

1 Like

Both version are compatible, but if you are looking for the most stable one I would recommend python 2.7 as python 3 will only be the default language for v12 (there has been no requirement to move Bench to python 3 in v11)


Keep this in mind too: Node.js still has Python 2 as a dependency. Until that’s resolved, you’ll need that installed anyway. Even if you’re doing all other development with Python 3.


Internally we are running both 2 and 3 in production. But if you are on V11, you should move to Python 3 to be future ready.


Also note that the automated tests routinely run on both Python 2.7 and 3.6, but also both MariaDB and Postgres.

Plus the UI tests now run on Cypress Bringing back UI Tests using Cypress

I guess the most straight forward way to be on phyton3 is by running the inital bench init command with the --python-version flag but the way this comment is constructed their seems to be a way to migrate to python3 on existing Frappé/ERPNext instances as well. Can anybody point out the details of such a process?

bench migrate-env python3.6
To go back:
bench migrate-env python2.7
If you like speed at the expense of some compatibility:
bench migrate-env pypy


looks like command needs to be bench migrate-env python3 (where /usr/bin/python3 actually is a symlink to 3.5)

lrwxrwxrwx 1 root root 9 Mar 23 2016 python3 -> python3.5)

getting problems with bench update after the switch to p3 though

DEBUG:bench.commands:Migration Successful to /usr/bin/python3
bench@ubn1604:~/frappe-bench$ bench restart
bench@ubn1604:~/frappe-bench$ bench update
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 19 (delta 10), reused 8 (delta 8), pack-reused 2
Unpacking objects: 100% (19/19), done.
   651856b..97b2891  master     -> origin/master
Updating 651856b..97b2891
Fast-forward             |  2 +-
 bench/config/ | 18 +++++++++++++++++-
 playbooks/  |  5 +++++
 playbooks/site.yml    | 32 ++++++++++++++++----------------
 4 files changed, 39 insertions(+), 18 deletions(-)
remote: Enumerating objects: 162, done.
remote: Counting objects: 100% (162/162), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 205 (delta 148), reused 152 (delta 148), pack-reused 43
Receiving objects: 100% (205/205), 45.55 KiB | 0 bytes/s, done.
Resolving deltas: 100% (157/157), completed with 86 local objects.
   e9a1ad5..0e5d378  staging    -> upstream/staging
   d5fdc67..1197271  develop    -> upstream/develop
   12798c9..0e5d378  staging-fixes -> upstream/staging-fixes
 * [new tag]         v11.0.3-beta.47 -> v11.0.3-beta.47
INFO:bench.utils:./env/bin/pip install Pillow
Requirement already satisfied: Pillow in ./env/lib/python3.5/site-packages (5.4.0) frappe
INFO:bench.utils:git pull  upstream staging
 * branch            staging    -> FETCH_HEAD
Updating e9a1ad5..0e5d378
 frappe/contacts/report/addresses_and_contacts/      |  30 +++-----
 frappe/contacts/report/addresses_and_contacts/ | 106 +++++++++++++++++++++++++++++
 frappe/core/doctype/transaction_log/                                |  16 +++++
 frappe/core/doctype/transaction_log/transaction_log.json                     |   5 +-
 frappe/core/doctype/transaction_log/                       |   6 +-
 frappe/core/doctype/view_log/test_view_log.js                                |   6 +-
 frappe/core/doctype/view_log/                                |   4 +-
 frappe/core/doctype/view_log/view_log.js                                     |   2 +-
 frappe/core/doctype/view_log/view_log.json                                   | 291 +++++++++++++++++++++++++++++++++++++++---------------------------------------
 frappe/core/doctype/view_log/                                     |   2 +-
 frappe/core/report/transaction_log_report/transaction_log_report.js          |   8 ++-
 frappe/core/report/transaction_log_report/transaction_log_report.json        |   5 +-
 frappe/core/report/transaction_log_report/          |   7 +-
 frappe/desk/form/                                                     |   2 +-
 frappe/                                                              |   2 +-
 frappe/integrations/doctype/dropbox_settings/dropbox_settings.json           |   2 +-
 frappe/model/                                                   |   4 +-
 frappe/model/                                                     |   2 +-
 frappe/patches.txt                                                           |   6 +-
 frappe/patches/v11_0/                           |  27 ++++++++
 frappe/                                                        |   4 +-
 frappe/public/js/frappe/chat.js                                              |   4 +-
 frappe/public/js/frappe/form/footer/timeline.js                              |   2 +-
 frappe/public/js/frappe/views/reports/query_report.js                        |   4 +-
 frappe/tests/                                                |  30 ++++++++
 frappe/tests/                                                  |  11 +--
 frappe/tests/                                             |  10 +++
 frappe/website/                                                      |   2 +
 28 files changed, 400 insertions(+), 200 deletions(-)
 create mode 100644 frappe/contacts/report/addresses_and_contacts/
 create mode 100644 frappe/core/doctype/transaction_log/
 create mode 100644 frappe/patches/v11_0/
INFO:bench.utils:find . -name "*.pyc" -delete frappe_io
INFO:bench.utils:git pull  upstream master
 * branch            master     -> FETCH_HEAD
Already up-to-date.
INFO:bench.utils:find . -name "*.pyc" -delete erpnext
INFO:bench.utils:git pull  upstream staging
remote: Enumerating objects: 444, done.
remote: Counting objects: 100% (317/317), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 164 (delta 132), reused 135 (delta 104), pack-reused 0
Receiving objects: 100% (164/164), 25.07 KiB | 0 bytes/s, done.
Resolving deltas: 100% (132/132), completed with 33 local objects.
 * branch            staging    -> FETCH_HEAD
   1fa3f7d..094d539  staging    -> upstream/staging
Updating 1fa3f7d..094d539
 erpnext/accounts/report/                             |   2 +-
 erpnext/accounts/report/sales_payment_summary/      |  60 ++++++++++++-----------
 erpnext/accounts/report/sales_payment_summary/ | 165 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 erpnext/                                                            |   2 +-
 erpnext/hr/doctype/department/                            |  17 ++++++-
 erpnext/hr/doctype/employee/                                     |  16 ++++--
 erpnext/hr/doctype/employee/                                |  13 +++++
 erpnext/hr/doctype/leave_application/              |   2 +-
 erpnext/hr/doctype/upload_attendance/              |  33 +++++++++++++
 erpnext/hr/doctype/upload_attendance/                   |  33 ++++++++++---
 erpnext/manufacturing/doctype/bom_item/bom_item.json                        | 210 ++++++++++++++++++++++++-------------------------------------------------------
 erpnext/projects/doctype/timesheet/                        |   2 +
 erpnext/utilities/                                       |  14 +++++-
 13 files changed, 376 insertions(+), 193 deletions(-)
 create mode 100644 erpnext/accounts/report/sales_payment_summary/
 create mode 100644 erpnext/hr/doctype/upload_attendance/
INFO:bench.utils:find . -name "*.pyc" -delete foundation
INFO:bench.utils:git pull  upstream master
 * branch            master     -> FETCH_HEAD
Already up-to-date.
INFO:bench.utils:find . -name "*.pyc" -delete bookingapp
INFO:bench.utils:git pull  upstream master
 * branch            master     -> FETCH_HEAD
Already up-to-date.
INFO:bench.utils:find . -name "*.pyc" -delete
Updating Python libraries...
INFO:bench.utils:./env/bin/pip install --upgrade pip
Requirement already up-to-date: pip in ./env/lib/python3.5/site-packages (18.1)
INFO:bench.utils:./env/bin/pip install -q -r /opt/bench/bench-repo/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/frappe_io/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/erpnext/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/foundation/requirements.txt
INFO:bench.utils:./env/bin/pip install -q -r ./apps/bookingapp/requirements.txt
Updating node packages...
INFO:bench.utils:yarn install
yarn install v1.12.3
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.64s.
Backing up sites...
Traceback (most recent call last):
  File "/usr/lib/python3.5/", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.5/", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 97, in <module>
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 18, in main
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/click/", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/click/", line 717, in main
    rv = self.invoke(ctx)
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/click/", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/click/", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/click/", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/click/", line 555, in invoke
    return callback(*args, **kwargs)
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/click/", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/opt/bench/frappe-bench/apps/frappe/frappe/commands/", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/opt/bench/frappe-bench/apps/frappe/frappe/commands/", line 302, in backup
    odb = scheduled_backup(ignore_files=not with_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, backup_path_private_files=backup_path_private_files, force=True)
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 172, in scheduled_backup
    odb = new_backup(older_than, ignore_files, backup_path_db=backup_path_db, backup_path_files=backup_path_files, force=force)
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 182, in new_backup
    odb.get_backup(older_than, ignore_files, force=force)
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 48, in get_backup
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 63, in set_backup_file_name
    todays_date = now_datetime().strftime('%Y%m%d_%H%M%S')
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 121, in now_datetime
    dt = convert_utc_to_user_timezone(datetime.datetime.utcnow())
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 144, in convert_utc_to_user_timezone
    return utcnow.astimezone(timezone(get_time_zone()))
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 138, in get_time_zone
    return frappe.cache().get_value("time_zone", _get_time_zone)
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 72, in get_value
    val = generator()
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 132, in _get_time_zone
    return frappe.db.get_system_setting('time_zone') or 'Asia/Kolkata' # Default to India ?!
  File "/opt/bench/frappe-bench/apps/frappe/frappe/", line 943, in get_system_setting
    return frappe.cache().get_value("system_settings", _load_system_settings).get(key)
  File "/opt/bench/frappe-bench/apps/frappe/frappe/utils/", line 72, in get_value
    val = generator()
  File "/opt/bench/frappe-bench/apps/frappe/frappe/", line 942, in _load_system_settings
    return self.get_singles_dict("System Settings")
  File "/opt/bench/frappe-bench/apps/frappe/frappe/", line 603, in get_singles_dict
    """, doctype)
  File "/opt/bench/frappe-bench/apps/frappe/frappe/", line 165, in sql
  File "/opt/bench/frappe-bench/apps/frappe/frappe/", line 115, in connect
    charset='utf8mb4', use_unicode = True, conv = conversions, local_infile = self.local_infile)
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/pymysql/", line 94, in Connect
    return Connection(*args, **kwargs)
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/pymysql/", line 325, in __init__
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/pymysql/", line 599, in connect
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/pymysql/", line 861, in _request_authentication
    auth_packet = self._read_packet()
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/pymysql/", line 684, in _read_packet
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/pymysql/", line 220, in check_error
  File "/opt/bench/frappe-bench/env/lib/python3.5/site-packages/pymysql/", line 109, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1045, "Access denied for user '7a6f4ef655be499a'@'localhost' (using password: YES)")

Any pointer how to get passed this? is this a mariadb access issue for the 7a6f4ef655be499a user? It wasn’t a problem prior the migration.

Also I have one custom app running. can this be the problem?

yea. that was the problem. ran bench uninstall-app bookingapp & bench remove-from-installed-apps bookingapp and all goes well.


So to upgrade for python 3, I have to remove the custom applications and then re-install it?


1 Like

Have you tried it? Will we have to remove custom app and then install it again after migrating to Python 3?

Tried it many times for many different apps. It’s completely case by case, just uninstalling and reinstalling isn’t going to fix it. Most often the problem is with pip, but I’ve had problems migrating with import statements as well.


If python3 is more stable with v11 then why is it not installed by default?

1 Like

Could you explain better the meaning of “at the expense of some compatibility” if I want to use pypy?
Speed is something always nice to get, but what compatibility I have to sacrifice to get that?

1 Like

Sagar has done more experimentation with this than I and my opinion is based on having used it without issues, but Sagar mentioned that there were specific incompatibilities with PDF generation. If you need everything about Frappe and ERPNext to work, that’s not a reasonable expectation, because pypy is not included in any test suites.

1 Like

If the issues regarding PDF, i could try a dev env and check what’s going on.
But if ERP Next is not tested officially with pypy, i will not use it in any prod env

We’re facing the same issue with Python 3, we upgraded to python 3 and not PDF aligned and letterhead print is broken. We have try to do everything possible but I cant seem to find any solution.

Before it was not even previewing in pdf, would take around 5-10mins to load pdf and blocking the server usage, But just upgraded to the latest v11 release and the pdf would load fast but with broken css.

Also when we try to move back to python2.7 then its internal server error and bench update is also broken coz of pickle.

Yes I got the same error too

How to solve this pickle error?