[Guide] How to install ERPNext v14 on Linux Ubuntu (step-by-step instructions)

Im trying to install hrms app into my site called hrms.site, i have installed it before but due to verision issues i uninstalled it but when i try reinstalling the correct version im getting this error

App erpnext already installed

Installing hrms...
Updating DocTypes for hrms          : [========================================] 100%
Setting up Frappe HR...
Installation for Frappe HR app failed due to an error. Please try re-installing the app or report the issue on https://github.com/frappe/hrms/issues/new if not resolved.
An error occurred while installing hrms: ('Role Profile', 'HR', IntegrityError(1062, "Duplicate entry 'HR' for key 'PRIMARY'"))
Traceback (most recent call last):
  File "apps/frappe/frappe/model/base_document.py", line 517, in db_insert
    frappe.db.sql(
  File "apps/frappe/frappe/database/database.py", line 220, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 158, in execute
    result = self._query(query)
  File "env/lib/python3.10/site-packages/pymysql/cursors.py", line 325, in _query
    conn.query(q)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 549, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 779, in _read_query_result
    result.read()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 1157, in read
    first_packet = self.connection._read_packet()
  File "env/lib/python3.10/site-packages/pymysql/connections.py", line 729, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.10/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.10/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.IntegrityError: (1062, "Duplicate entry 'HR' for key 'PRIMARY'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 415, in install_app
    _install_app(app, verbose=context.verbose, force=force)
  File "apps/frappe/frappe/installer.py", line 307, in install_app
    frappe.get_attr(after_install)()
  File "apps/hrms/hrms/install.py", line 21, in after_install
    raise e
  File "apps/hrms/hrms/install.py", line 9, in after_install
    setup()
  File "apps/hrms/hrms/setup.py", line 22, in after_install
    create_default_role_profiles()
  File "apps/hrms/hrms/setup.py", line 712, in create_default_role_profiles
    role_profile.insert(ignore_permissions=True)
  File "apps/frappe/frappe/model/document.py", line 272, in insert
    self.db_insert(ignore_if_duplicate=ignore_if_duplicate)
  File "apps/frappe/frappe/model/base_document.py", line 544, in db_insert
    raise frappe.DuplicateEntryError(self.doctype, self.name, e)
frappe.exceptions.DuplicateEntryError: ('Role Profile', 'HR', IntegrityError(1062, "Duplicate entry 'HR' for key 'PRIMARY'"))

Please help me resolve the issue

Bench version is :
erpnext 14.43.0
frappe 14.51.0
payments 0.0.1

I want hrms 14.13.0
bench get-app hrms --branch version-14

is there any mistake

do the following things:

  1. Turn on Developer Mode (if you are on a production server)
  2. bench remove-app hrms
  3. bench --site [your site] uninstall-app hrms
  4. bench clear-cache
  5. bench clear-website-cache
  6. bench update --migrate
  7. bench get-app --branch version-14 hrms
  8. bench --site [your site] install-app hrms

If you have not setup the production mode of your setup, then your must keep the bench running in another terminal. Make sure that the bench is not stopped during the installation of hrms app or you will keep facing an error.

Moreover, you may refer to this video for step by step guidance of Installing ERPNext on Ubuntu Server:

1 Like

For me installation worked when collation_server was updated in file /etc/mysql/mariadb.conf.d/50-server.cnf

I tried the steps in the video in another directory, even installed the packages again so that i dont miss out, but after installation of the bench if i start it to create new site its stoping immediately

bench start
11:34:36 system        | redis_cache.1 started (pid=54810)
11:34:36 system        | redis_queue.1 started (pid=54814)
11:34:36 system        | web.1 started (pid=54818)
11:34:36 system        | socketio.1 started (pid=54819)
11:34:36 system        | watch.1 started (pid=54826)
11:34:36 system        | schedule.1 started (pid=54827)
11:34:36 redis_queue.1 | 54817:C 10 Oct 2023 11:34:36.423 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
11:34:36 system        | worker.1 started (pid=54832)
11:34:36 redis_cache.1 | 54813:C 10 Oct 2023 11:34:36.423 # WARNING Memory overcommit must be enabled! Without it, a background save or replication may fail under low memory condition. Being disabled, it can also cause failures without low memory condition, see https://github.com/jemalloc/jemalloc/issues/1328. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
11:34:36 redis_queue.1 | 54817:C 10 Oct 2023 11:34:36.423 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11:34:36 redis_cache.1 | 54813:C 10 Oct 2023 11:34:36.423 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11:34:36 redis_queue.1 | 54817:C 10 Oct 2023 11:34:36.423 * Redis version=7.2.1, bits=64, commit=00000000, modified=0, pid=54817, just started
11:34:36 redis_cache.1 | 54813:C 10 Oct 2023 11:34:36.423 * Redis version=7.2.1, bits=64, commit=00000000, modified=0, pid=54813, just started
11:34:36 redis_queue.1 | 54817:C 10 Oct 2023 11:34:36.423 * Configuration loaded
11:34:36 redis_cache.1 | 54813:C 10 Oct 2023 11:34:36.423 * Configuration loaded
11:34:36 redis_queue.1 | 54817:M 10 Oct 2023 11:34:36.424 * Increased maximum number of open files to 10032 (it was originally set to 1024).
11:34:36 redis_queue.1 | 54817:M 10 Oct 2023 11:34:36.424 * monotonic clock: POSIX clock_gettime
11:34:36 redis_cache.1 | 54813:M 10 Oct 2023 11:34:36.424 * Increased maximum number of open files to 10032 (it was originally set to 1024).
11:34:36 redis_cache.1 | 54813:M 10 Oct 2023 11:34:36.424 * monotonic clock: POSIX clock_gettime
11:34:36 redis_queue.1 | 54817:M 10 Oct 2023 11:34:36.424 * Running mode=standalone, port=11000.
11:34:36 redis_queue.1 | 54817:M 10 Oct 2023 11:34:36.424 # Warning: Could not create server TCP listening socket 127.0.0.1:11000: bind: Address already in use
11:34:36 redis_queue.1 | 54817:M 10 Oct 2023 11:34:36.424 # Failed listening on port 11000 (tcp), aborting.
11:34:36 redis_cache.1 | 54813:M 10 Oct 2023 11:34:36.424 * Running mode=standalone, port=13000.
11:34:36 redis_cache.1 | 54813:M 10 Oct 2023 11:34:36.424 # Warning: Could not create server TCP listening socket 127.0.0.1:13000: bind: Address already in use
11:34:36 redis_cache.1 | 54813:M 10 Oct 2023 11:34:36.424 # Failed listening on port 13000 (tcp), aborting.
11:34:36 system        | redis_queue.1 stopped (rc=1)
11:34:36 system        | sending SIGTERM to redis_cache.1 (pid 54810)
11:34:36 system        | sending SIGTERM to web.1 (pid 54818)
11:34:36 system        | sending SIGTERM to socketio.1 (pid 54819)
11:34:36 system        | sending SIGTERM to watch.1 (pid 54826)
11:34:36 system        | sending SIGTERM to schedule.1 (pid 54827)
11:34:36 system        | sending SIGTERM to worker.1 (pid 54832)
11:34:36 system        | redis_cache.1 stopped (rc=1)
11:34:36 system        | watch.1 stopped (rc=-15)
11:34:36 system        | web.1 stopped (rc=-15)
11:34:36 system        | schedule.1 stopped (rc=-15)
11:34:36 system        | worker.1 stopped (rc=-15)
11:34:36 system        | socketio.1 stopped (rc=-15)

any help from your side would be appreciated, Im not able to detect the error why is my bench suddenly stopping this way

Are you executing the commands from root user???

if so, them you need to do the following…

  1. Create a fresh Ubuntu Virtual Server
  2. Set your timezone correctly.
  3. Create a user named “frappe”
  4. Give this user the sudo privileges.
  5. login to server using this user
  6. execute all the commands one by one in same sequence as explained in the video.
  7. I am sure you won’t have any errors after following these steps…
1 Like

Yes! I did that sir now its working fine, Thanks for the video helped me a lot

In such case, you should mark the support as a solution…

The original poster can do that.
And the original post was not a question to begin with.
In such cases the solution marking doesn’t work as a reward or end of thread system.

Maybe the solution for such threads could only be a change in the software, a change which obsoletes the questions and difficulties the original post (a guide) tries to be a solution for.
Assuring an accurate assesment in this sense would not be easy to do with some single click.

Thanks @Peer for your explanation. I was not aware of this…

The latest major version of Frappe & ERPNext v15 is released and this guide continues to work with a few minor tweaks to the version numbers.

Here’s the v15 installation guide: [Guide] How to install ERPNext v15 on Linux Ubuntu (step-by-step instructions)


What is the issue ?

Looks like your development server is running just fine.

Try to access it at http://172.31.87.184:8000 or http://127.0.0.1:8000 (= http://localhost:8000)

Did you create a site yet? If so, try that name, like http://your-site-name:8000

This is coming while accessing

This looks like you accessed your server, but you didn’t create a site yet.
You can confirm this if the log on the bench (or server) screen (like the one you showed further above) shows some entry when you access it (an error in this case). That means that the server is running, serves the error as it should, because you didn’t configure a site yet.

So I think you should continue from here:
https://frappeframework.com/docs/user/en/tutorial/create-a-site
and once you created a site, like for instance “my-frappe.localhost”, try to access it at this name, e.g. http://my-frappe.localhost:8000
There should be a login form with which you can access the frappe framework.

Once this works, you can install an app, depending on what you want installed on your site.

From what i can see, you installed a development environment in a cloud VPS. and i suspect that the port 8000 is not open in your vps. Check to see if that port is open and if not, open the port.

Yes better to switch to Version 15 because many installs fail on 14 as I also noticed.

I am using docker now because the scripting got over the top as over 250 posts on this thread show.

On Docker you can also integrate your custom apps or any other public available frappe apps:

Good luck. The start will not be easy and you really need to understand and read about what is going on.

Not necessarily. This script installs Versions 13, 14 or 15 successfully with very minimal interaction.

You can try it out.

Hello everyone, i tried almost everything but stuck at this error while installing erpnext v14.

I’m using UBUNTU 24 LATEST AS A OS in my system.

frappe@Rahul:~$ sudo 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.

Any help appreciated, Thank You

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”

Python 3.12 which is the default in Ubuntu 24 isn’t yet supported. You have to change your OS to Ubuntu 22.04