Dropping python <=3.9 support for next version of Frappe/ERPNext

I have also faced the same issue in develop branch when installing the erpnext app.

Frappe installed successfully and it’s worked fine but when I get the erpnext app then

bench get-app erpnext https://github.com/frappe/erpnext
WARN: bench is installed in editable mode!

This is not the recommended mode of installation for production. Instead, install the package from PyPI with: `pip install frappe-bench`

Getting erpnext
$ git clone https://github.com/frappe/erpnext --depth 1 --origin upstream
Cloning into 'erpnext'...
remote: Enumerating objects: 5932, done.
remote: Counting objects: 100% (5932/5932), done.
remote: Compressing objects: 100% (4958/4958), done.
remote: Total 5932 (delta 1213), reused 2853 (delta 695), pack-reused 0
Receiving objects: 100% (5932/5932), 18.28 MiB | 152.00 KiB/s, done.
Resolving deltas: 100% (1213/1213), done.
Ignoring dependencies of https://github.com/frappe/erpnext. To install dependencies use --resolve-deps
Installing erpnext
$ /home/scs/ERPNext_Develop/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/scs/ERPNext_Develop/frappe-bench/apps/erpnext
 error: subprocess-exited-with-error
 
 × python setup.py bdist_wheel did not run successfully.
 │ exit code: 1
 ╰─> [26 lines of output]
   /tmp/pip-install-i7se33_q/hiredis_b40174a4d351454e90e7d1b1a01dcc51/setup.py:7: DeprecationWarning: the imp module is deprecated in favour of importlib and slated for removal in Python 3.12; see the module's documentation for alternative uses
    import sys, imp, os, glob, io
   /home/scs/ERPNext_Develop/frappe-bench/env/lib/python3.10/site-packages/setuptools/dist.py:723: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead
    warnings.warn(
   running bdist_wheel
   running build
   running build_py
   creating build
   creating build/lib.linux-x86_64-3.10
   creating build/lib.linux-x86_64-3.10/hiredis
   copying hiredis/__init__.py -> build/lib.linux-x86_64-3.10/hiredis
   copying hiredis/version.py -> build/lib.linux-x86_64-3.10/hiredis
   copying hiredis/hiredis.pyi -> build/lib.linux-x86_64-3.10/hiredis
   copying hiredis/py.typed -> build/lib.linux-x86_64-3.10/hiredis
   running build_ext
   creating build/temp.linux-x86_64-3.10
   creating build/temp.linux-x86_64-3.10/src
   creating build/temp.linux-x86_64-3.10/vendor
   creating build/temp.linux-x86_64-3.10/vendor/hiredis
   x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ivendor -I/home/scs/ERPNext_Develop/frappe-bench/env/include -I/usr/include/python3.10 -c src/hiredis.c -o build/temp.linux-x86_64-3.10/src/hiredis.o
   In file included from src/hiredis.c:1:
   src/hiredis.h:4:10: fatal error: Python.h: No such file or directory
     4 | #include <Python.h>
      |     ^~~~~~~~~~
   compilation terminated.
   error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
   [end of output]
 
 note: This error originates from a subprocess, and is likely not a problem with pip.
 ERROR: Failed building wheel for hiredis
 error: subprocess-exited-with-error
 
 × python setup.py bdist_wheel did not run successfully.
 │ exit code: 1
 ╰─> [23 lines of output]
   You are running without Cython installed. It is highly recommended to run
    pip install cython>=0.29.21,<1.0.0
   before you continue
   /home/scs/ERPNext_Develop/frappe-bench/env/lib/python3.10/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
    warnings.warn(
   Warning: 'classifiers' should be a list, got type 'tuple'
   running bdist_wheel
   running build
   running build_py
   creating build
   creating build/lib.linux-x86_64-3.10
   creating build/lib.linux-x86_64-3.10/jsonobject
   copying jsonobject/__init__.py -> build/lib.linux-x86_64-3.10/jsonobject
   copying jsonobject/exceptions.py -> build/lib.linux-x86_64-3.10/jsonobject
   running build_ext
   creating build/temp.linux-x86_64-3.10
   creating build/temp.linux-x86_64-3.10/jsonobject
   x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/scs/ERPNext_Develop/frappe-bench/env/include -I/usr/include/python3.10 -c jsonobject/api.c -o build/temp.linux-x86_64-3.10/jsonobject/api.o
   jsonobject/api.c:18:10: fatal error: Python.h: No such file or directory
    18 | #include "Python.h"
      |     ^~~~~~~~~~
   compilation terminated.
   error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
   [end of output]
 
 note: This error originates from a subprocess, and is likely not a problem with pip.
 ERROR: Failed building wheel for jsonobject
 error: subprocess-exited-with-error
 
 × Running setup.py install for jsonobject did not run successfully.
 │ exit code: 1
 ╰─> [25 lines of output]
   You are running without Cython installed. It is highly recommended to run
    pip install cython>=0.29.21,<1.0.0
   before you continue
   /home/scs/ERPNext_Develop/frappe-bench/env/lib/python3.10/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
    warnings.warn(
   Warning: 'classifiers' should be a list, got type 'tuple'
   running install
   /home/scs/ERPNext_Develop/frappe-bench/env/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
    warnings.warn(
   running build
   running build_py
   creating build
   creating build/lib.linux-x86_64-3.10
   creating build/lib.linux-x86_64-3.10/jsonobject
   copying jsonobject/__init__.py -> build/lib.linux-x86_64-3.10/jsonobject
   copying jsonobject/exceptions.py -> build/lib.linux-x86_64-3.10/jsonobject
   running build_ext
   creating build/temp.linux-x86_64-3.10
   creating build/temp.linux-x86_64-3.10/jsonobject
   x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/home/scs/ERPNext_Develop/frappe-bench/env/include -I/usr/include/python3.10 -c jsonobject/api.c -o build/temp.linux-x86_64-3.10/jsonobject/api.o
   jsonobject/api.c:18:10: fatal error: Python.h: No such file or directory
    18 | #include "Python.h"
      |     ^~~~~~~~~~
   compilation terminated.
   error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
   [end of output]
 
 note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> jsonobject

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

How to resolve issue @ankush.

Experiencing the same problem while installing Frappe and ERPNext version 13

Using Python 3.10

@NCP that appears to be due to missing development libraries.

If you’re running python you need to install python{version-string}-dev package too, that’s complete python distribution; by default ubuntu might not be installing development packages.

2 Likes

Resolved by installing python{version-string}-dev

Ohh great @ankush :partying_face:

I resolved the issue for develop branch by python{version-string}-dev

sudo apt install python3.10-dev

I was stuck for two days then after resolved.

Thank You!

2 Likes

@ankush I already have Python 3.8.10 . If I install sudo apt install python3.10-dev this any problem raised in future when gaving bench start. Please let me know

Thanks In Advance!

I am also having the same challenge, I installed python3.10 manually and I now have both versions 3.8.10 and 3.10 and also ran also sudo apt install python3.10-dev and installed the packages but am still getting >> ERROR: Package ‘frappe’ requires a different Python: 3.8.10 not in ‘>=3.10’

1 Like
3 Likes

Ok thank you, I have followed your suggesting to the tee, but am still getting the same error, I have even set python 3.10 on auto mode;

here are 2 choices for the alternative python (providing /usr/bin/python).

Selection Path Priority Status

  • 0 /usr/bin/python3.10 2 auto mode
    1 /usr/bin/python3.10 2 manual mode
    2 /usr/bin/python3.8 1 manual mode

am not sure if I should also change the enviroment, please take note this is a fresh installation and am failing to bench init

This problem took me few days also and I fix it by follow this link

Upgrade Python to latest version (3.10) on Ubuntu Linux (cloudbytes.dev)

Thank you this worked for me very well until I started hit a snag when now try to ran bench setup production (username) : I am getting an error associated with python3-apt, let me paste the error below

TASK [fail2ban : Install fail2ban] *****************************************************************************************************************************
task path: /usr/local/lib/python3.10/dist-packages/bench/playbooks/roles/fail2ban/tasks/main.yml:6
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c ‘echo ~root && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /root/.ansible/tmp”&& mkdir “echo /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888” && echo ansible-tmp-1658325828.2886786-1834-7555114602888=“echo /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888” ) && sleep 0’
Using module file /usr/local/lib/python3.10/dist-packages/ansible/modules/apt.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-1773cnt95zto/tmpf8oz70cl TO /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888/AnsiballZ_apt.py
<127.0.0.1> EXEC /bin/sh -c ‘chmod u+x /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888/ /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888/AnsiballZ_apt.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘/usr/bin/python3.10 /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888/AnsiballZ_apt.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘rm -f -r /root/.ansible/tmp/ansible-tmp-1658325828.2886786-1834-7555114602888/ > /dev/null 2>&1 && sleep 0’
[WARNING]: Updating cache and auto-installing missing dependency: python3-apt
fatal: [localhost]: FAILED! => {
“changed”: false,
“invocation”: {
“module_args”: {
“allow_change_held_packages”: false,
“allow_downgrade”: false,
“allow_unauthenticated”: false,
“autoclean”: false,
“autoremove”: false,
“cache_valid_time”: 0,
“clean”: false,
“deb”: null,
“default_release”: null,
“dpkg_options”: “force-confdef,force-confold”,
“fail_on_autoremove”: false,
“force”: false,
“force_apt_get”: false,
“install_recommends”: null,
“lock_timeout”: 60,
“name”: “fail2ban”,
“only_upgrade”: false,
“package”: [
“fail2ban”
],
“policy_rc_d”: null,
“purge”: false,
“state”: “present”,
“update_cache”: null,
“update_cache_retries”: 5,
“update_cache_retry_max_delay”: 12,
“upgrade”: “no”
}
},
“msg”: “python3-apt must be installed and visible from /usr/bin/python3.10.”
}

PLAY RECAP *****************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=1 rescued=0 ignored=0

ERROR: Command ‘[‘ansible-playbook’, ‘-c’, ‘local’, ‘site.yml’, ‘-vvvv’, ‘-e’, ‘{“production”: true, “admin_emails”: “”, “mysql_root_password”: null, “container”: false}’, ‘-t’, ‘fail2ban’]’ returned non-zero exit status 2.
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 8, in
sys.exit(cli())
File “/usr/local/lib/python3.10/dist-packages/bench/cli.py”, line 121, in cli
raise e
File “/usr/local/lib/python3.10/dist-packages/bench/cli.py”, line 111, in cli
bench_command()
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1130, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1055, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 760, in invoke
return __callback(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py”, line 273, in setup_roles
run_playbook(“site.yml”, extra_vars=extra_vars, tag=role)
File “/usr/local/lib/python3.10/dist-packages/bench/utils/init.py”, line 322, in run_playbook
subprocess.check_call(args, cwd=os.path.join(bench.path[0], “playbooks”))
File “/usr/lib/python3.10/subprocess.py”, line 369, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command ‘[‘ansible-playbook’, ‘-c’, ‘local’, ‘site.yml’, ‘-vvvv’, ‘-e’, ‘{“production”: true, “admin_emails”: “”, “mysql_root_password”: null, “container”: false}’, ‘-t’, ‘fail2ban’]’ returned non-zero exit status 2.
ERROR:
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 8, in
sys.exit(cli())
File “/usr/local/lib/python3.10/dist-packages/bench/cli.py”, line 121, in cli
raise e
File “/usr/local/lib/python3.10/dist-packages/bench/cli.py”, line 111, in cli
bench_command()
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1130, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1055, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python3.10/dist-packages/click/core.py”, line 760, in invoke
return __callback(*args, **kwargs)
File “/usr/local/lib/python3.10/dist-packages/bench/commands/setup.py”, line 72, in setup_production
setup_production(user=user, yes=yes)
File “/usr/local/lib/python3.10/dist-packages/bench/config/production_setup.py”, line 33, in setup_production
setup_production_prerequisites()
File “/usr/local/lib/python3.10/dist-packages/bench/config/production_setup.py”, line 24, in setup_production_prerequisites
exec_cmd(“bench setup role fail2ban”)
File “/usr/local/lib/python3.10/dist-packages/bench/utils/init.py”, line 153, in exec_cmd
raise CommandFailedError
bench.exceptions.CommandFailedError

I have tried to follow other solutions on the net like

cd /usr/lib/python3/dist-packages

and pasting these two;

sudo ln -s apt_inst.cpython-38m-x86_64-linux-gnu.so apt_inst.so
sudo ln -s apt_pkg.cpython-38m-x86_64-linux-gnu.so apt_pkg.so

since am not sure what version 3.10 uses for these files i left them as for version 3.8

I also did the same on this route

/usr/local/lib/python3.10/dist-packages

Am still getting the same error not sure if you had success. Am using ubuntu 20.04LTS , am considering reinstalling the OS and try again

Hi,

If you decide to start with a fresh OS , consider Ubuntu 22.04 LTS as it has python3.10 as default. That might make things easier.

Thank you let try that will get back

I have managed to get to work thank you for your assistance. This made me document each every step which am going to post, maybe it will help someone in similar situation

I think python 3.9 need to be supported since Debian and one of the RPM based distro Stream has python install defaults with this version. There are upgrade install using tarballs for pyhton version 3.10 but that is another story.

Hi, can you send the step by step instruction to install ERPNext version 14 (stable) on ubuntu 20.04 or 22.04?

You can consider checking this

I am getting started with Frappe Framework, But I am getting this error. Does anybody know how to fix it.

Hi @blaiseAI,

If you installing version 14 then apply it.

bench init frappe-bench --frappe-path https://github.com/frappe/frappe --frappe-branch version-14 --python python3.10
2 Likes

Thanks you, I will bookmark this manual option. I had tried using Docker and I think I prefer that way as I don’t run into dependency issues.