Install Frappe framework in Ubuntu24.04 LTS ( Pip3 install frappe-bench )

Dear Frappe community,
I bought a new laptop with Ubuntu 24.04 LTS OS ,
I couldn’t install frappe-bench using pip3 install method, This is what I got:

~$ pip3 install frappe-bench
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    
    See /usr/share/doc/python3.12/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Please anyone could help ?

for your information I used pipx install after I installed pipx package , I installed , the frappe-bench using :
pipx install frappe-bench
then
cd frappe-bench

but I couldnot initiate the bench,
bench init frappe-bench , does not work,
here is what I got:

$ bench init frappe-bench
Setting Up Environment
$ python3 -m venv env
The virtual environment was not created successfully because ensurepip is not
available.  On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.

    apt install python3.12-venv

You may need to use sudo with that command.  After installing the python3-venv
package, recreate your virtual environment.

Failing command: /home/faris/bench-0/bench-0/env/bin/python3

subprocess.CalledProcessError: Command 'python3 -m venv env' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/faris/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/commands/make.py", line 75, in init
    init(
  File "/home/faris/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/utils/render.py", line 105, in wrapper_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/faris/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/utils/system.py", line 66, in init
    bench.setup.env(python=python)
  File "/home/faris/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/utils/render.py", line 126, in wrapper_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/faris/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/bench.py", line 362, in env
    self.run(f"{venv} env", cwd=self.bench.name)
  File "/home/faris/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/bench.py", line 48, in run
    return exec_cmd(cmd, cwd=cwd or self.cwd, _raise=_raise)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/faris/.local/share/pipx/venvs/frappe-bench/lib/python3.12/site-packages/bench/utils/__init__.py", line 169, in exec_cmd
    raise CommandFailedError(cmd) from subprocess.CalledProcessError(return_code, cmd)
bench.exceptions.CommandFailedError: python3 -m venv env

ERROR: There was a problem while creating bench-0
Do you want to rollback these changes? [y/N]:

The error message suggests that ensurepip is not available, which is required for creating the virtual environment.

sudo apt install python3-venv
1 Like

Thank you @Manav-Mandli for your interaction and help although I’m very new to this framework but it seems interesting :star_struck:

I browsed for the solution and I found this guide very helpful for me : GeekyShowsNotes

For anyone faced the same issue, It worked for me by using the following steps:

  • Install virtualenv:
sudo apt install python3-virtualenv
  • Install frappe-bench using pipx
sudo pipx install frappe-bench
  • Create Virtual env
cd ~/project_folder_name
Syntax:- virtualenv env_name
Example:- virtualenv frappe-bench
  • Activate Virtual env
Syntax:- source virtualenv_name/bin/activate
Example:- source frappe-bench/bin/activate

and everything works like a charm. :grinning:

1 Like

@Faris_Alsolmi
easiest way is to install with this script, thanks to @flexy2ky

1 Like

thank you @meraki , yeah it doesn’t work for Ubuntu 24.04 , I tried it before , that was because the changes that was done by python policy to secure the systems and Pip3 install doesn’t work anymore in root user as I understood, anyone can correct if i’m wrong because I don’t understand much in this aspect , and you can only setup virtual python env for your setup and use pipx instead of pip3 , for more information you can read here PEP 668

wish you all the best with frappe-framework :innocent:

2 Likes

frappe-bench) frappe@Rahul:~$ bench init --frappe-branch version-14 frappe-bench
Setting Up Environment
$ python3 -m venv env
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade pip
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet wheel
Getting frappe
$ git clone GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript --branch version-14 --depth 1 --origin upstream
Cloning into ‘frappe’…
remote: Enumerating objects: 3246, done.
remote: Counting objects: 100% (3246/3246), done.
remote: Compressing objects: 100% (2874/2874), done.
remote: Total 3246 (delta 374), reused 1884 (delta 261), pack-reused 0
Receiving objects: 100% (3246/3246), 16.34 MiB | 8.84 MiB/s, done.
Resolving deltas: 100% (374/374), done.
Installing frappe
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/frappe
ERROR: Ignored the following yanked versions: 3.6.0a1
ERROR: Ignored the following versions that require a different python version: 5.1 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.10; 5.2 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.11; 5.2a1.dev0 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.11; 5.3 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.11; 5.3a1.dev0 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.12; 5.4 Requires-Python >=2.7, !=3.0., !=3.1., !=3.2., !=3.3., !=3.4., <3.11; 6.0 Requires-Python >=3.6, <3.12; 6.0a1.dev0 Requires-Python >=3.6, <3.12; 6.1 Requires-Python >=3.6, <3.12; 6.2 Requires-Python >=3.6, <3.12
ERROR: Could not find a version that satisfies the requirement RestrictedPython~=6.2 (from frappe) (from versions: 3.4.2, 3.4.3, 3.5.0, 3.5.1, 3.5.2, 3.6.0, 4.0a1, 4.0a2, 4.0a3, 4.0b1, 4.0b2, 4.0b3, 4.0b4, 4.0b5, 4.0b6, 4.0b7, 4.0b8, 4.0, 5.0, 7.0a1.dev0, 7.0a1.dev1, 7.0a2.dev0, 7.0, 7.1, 7.2a1.dev0)
ERROR: No matching distribution found for RestrictedPython~=6.2
subprocess.CalledProcessError: Command '/home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/frappe ’ returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/local/lib/python3.12/dist-packages/bench/commands/make.py”, line 75, in init
init(
File “/usr/local/lib/python3.12/dist-packages/bench/utils/render.py”, line 105, in wrapper_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/dist-packages/bench/utils/system.py”, line 87, in init
get_app(
File “/usr/local/lib/python3.12/dist-packages/bench/app.py”, line 777, in get_app
app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench)
File “/usr/local/lib/python3.12/dist-packages/bench/utils/render.py”, line 126, in wrapper_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/dist-packages/bench/app.py”, line 254, in install
install_app(
File “/usr/local/lib/python3.12/dist-packages/bench/app.py”, line 909, in install_app
bench.run(
File “/usr/local/lib/python3.12/dist-packages/bench/bench.py”, line 48, in run
return exec_cmd(cmd, cwd=cwd or self.cwd, _raise=_raise)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/dist-packages/bench/utils/init.py”, line 178, in exec_cmd
raise CommandFailedError(cmd) from subprocess.CalledProcessError(return_code, cmd)
bench.exceptions.CommandFailedError: /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/frappe

ERROR: There was a problem while creating frappe-bench
Do you want to rollback these changes? [y/N]: y
INFO: Rolling back Bench “frappe-bench”

I’m getting this error

Hii @rs115199789

This error is caused by a Python compatibility issue where the version is higher than your current Python version, which is 3.6. For the next/development version of Frappe/ERPNext, 3.10 is the recommended and required version. For more information, visit: build!: Bump minimum Python version to 3.10 by gavindsouza · Pull Request #17355 · frappe/frappe · GitHub

To install a higher version of Python, use the following command:
sudo apt install python3.10-dev

2 Likes

i tried and get this error- frappe@Rahul:~$ sudo apt install python3.10-dev
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
python3.10-dev is already the newest version (3.10.14-1+noble2).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

shall i install ubuntu 22.04 and then try from start ?

Thank You

@rs115199789 What version of Ubuntu do you use ?

@Faris_Alsolmi
Brother I’m using Ubuntu 24.04 LTS

I believe there is no need to reinstall Ubuntu from scratch if you are still facing this issue, so try starting over.

just wanted to install erpnext v14 in ubuntu and run on local server for education, but stuck at this issue

if you have any other solutions do let me know thank you and yes I’m still facing this issues, everything is installed perfectly only this pip is creating issue, I’m not much into codes.

I was facing the same issue , then I installed frappe inside the python env,

cd frappe-bench

then:

source frappe-bench/bin/activate

then initiate your bench inside the python environment itself:

bench init --frappe-branch version-14 frappe-bench

I hope this could help you. Thank you

i tried but now getting this error- frappe@Rahul:~$ bench init frappe-bench
Setting Up Environment
$ python3 -m venv env
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade pip
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet wheel
Getting frappe
$ git clone GitHub - frappe/frappe: Low code web framework for real world applications, in Python and Javascript --depth 1 --origin upstream
Cloning into ‘frappe’…
remote: Enumerating objects: 3274, done.
remote: Counting objects: 100% (3274/3274), done.
remote: Compressing objects: 100% (2778/2778), done.
remote: Total 3274 (delta 509), reused 1685 (delta 383), pack-reused 0
Receiving objects: 100% (3274/3274), 11.42 MiB | 5.55 MiB/s, done.
Resolving deltas: 100% (509/509), done.
Installing frappe
$ /home/frappe/frappe-bench/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-bench/apps/frappe

$ yarn install --check-files
yarn install v1.22.22
[1/5] Validating package.json…
error frappe-framework@: The engine “node” is incompatible with this module. Expected version “>=18”. Got “16.15.0”
error Found incompatible module.
info Visit yarn install | Yarn for documentation about this command.
subprocess.CalledProcessError: Command ‘yarn install --check-files’ returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/local/lib/python3.12/dist-packages/bench/commands/make.py”, line 75, in init
init(
File “/usr/local/lib/python3.12/dist-packages/bench/utils/render.py”, line 105, in wrapper_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/dist-packages/bench/utils/system.py”, line 87, in init
get_app(
File “/usr/local/lib/python3.12/dist-packages/bench/app.py”, line 777, in get_app
app.install(verbose=verbose, skip_assets=skip_assets, restart_bench=restart_bench)
File “/usr/local/lib/python3.12/dist-packages/bench/utils/render.py”, line 126, in wrapper_fn
return fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/dist-packages/bench/app.py”, line 254, in install
install_app(
File “/usr/local/lib/python3.12/dist-packages/bench/app.py”, line 920, in install_app
bench.run(yarn_install, cwd=app_path)
File “/usr/local/lib/python3.12/dist-packages/bench/bench.py”, line 48, in run
return exec_cmd(cmd, cwd=cwd or self.cwd, _raise=_raise)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/dist-packages/bench/utils/init.py”, line 178, in exec_cmd
raise CommandFailedError(cmd) from subprocess.CalledProcessError(return_code, cmd)
bench.exceptions.CommandFailedError: yarn install --check-files

ERROR: There was a problem while creating frappe-bench

Did you switch to the python env? before you initiate your bench, the prompt in your temrinal will look like this :

(frappe-bench) frappe@Rahul: /frappe-bench$ 

then Initiate your bench:

bench init frappe-bench

Also, it seems that your node is less than 18 version, try update your nod and yarn versions from steps in this guide Frappe-ERPNext-Version-15–in-Ubuntu-22.04

espcially theses commoands:

nvm install 20
sudo apt-get install npm
sudo npm install -g yarn

@Faris_Alsolmi

again new error- frappe@Rahul:~$ source frappe-bench/bin/activate
(frappe-bench) frappe@Rahul:~$ bench init --frappe-branch version-14 frappe-bench
ERROR: Bench instance already exists at frappe-bench

I will download 22.04 and try to install erp again, if you have any solution or guide do share .

thank you

Hi Faris, Let me hijack you, I did all that and got an error. I posted here, Compose Fail To Start When Installing From Frappe-Manager on WSL2 Ubuntu 22.04

Hi @rs115199789 I exactly used the same steps , Install frappe framework on Ubuntu 24.04 LTS and it worked for me with errors.

@Faris_Alsolmi okay thanks alot for the guide ill try this if my ubuntu 22 fails, i re-install ubuntu 22 and tried to install erp, but when i try to create site it gives me error, you can check here- Bench new site create error

1 Like