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

I haven’t yet been able to successfully install production on CentOS as I highlighted here:

So I really can’t speak to the performance of the distros. I did try to compare between Debian and Ubuntu during my script development but the result varied even though the commands were essentially the same. But I will simulate again and if I discover anything new I will let you know.

Thank you @shashank_shirke For this guide. Works well !!

Just as a note … I also get the same error when installing HRMS and yet when I open my
ERPNext , HR and payroll has installed ???

I don’t get an error when using the PDF option on a doctype but it does look cut-off at the
edges. I will try the suggestion further up in this post.

Next step would be to migrate all my V13 databases to V14 !!!

I tried this but got the following error


bench --site nexus install-app hrms --force

Installing erpnext...
Updating DocTypes for erpnext       : [========================================] 100%
An error occurred while installing hrms: ('Role', 'Analytics', IntegrityError(1062, "Duplicate entry 'Analytics' for key 'PRIMARY'"))
Traceback (most recent call last):
  File "apps/frappe/frappe/model/base_document.py", line 502, in db_insert
    frappe.db.sql(
  File "apps/frappe/frappe/database/database.py", line 219, 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 'Analytics' 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 416, in install_app
    _install_app(app, verbose=context.verbose, force=force)
  File "apps/frappe/frappe/installer.py", line 269, in install_app
    install_app(required_app, verbose=verbose, force=force)
  File "apps/frappe/frappe/installer.py", line 304, in install_app
    frappe.get_attr(after_install)()
  File "apps/erpnext/erpnext/setup/install.py", line 22, in after_install
    frappe.get_doc({"doctype": "Role", "role_name": "Analytics"}).insert()
  File "apps/frappe/frappe/model/document.py", line 270, in insert
    self.db_insert(ignore_if_duplicate=ignore_if_duplicate)
  File "apps/frappe/frappe/model/base_document.py", line 529, in db_insert
    raise frappe.DuplicateEntryError(self.doctype, self.name, e)
frappe.exceptions.DuplicateEntryError: ('Role', 'Analytics', IntegrityError(1062, "Duplicate entry 'Analytics' for key 'PRIMARY'"))

I got this one yesterday too in a local development system. My fix was a bench reinstall , which will destroy your existing database. In my case that was fine, but you need to take a different approach if you’re trying to rescue an existing production system; if you are, send me a DM and we’ll work it out - it’s not related to this topic.

1 Like

Hello Shashank
Thank you for the guide steps, i want to run these steps to install Erpnext, but now i have Ubuntu 22.4 desktop version using VM-17 , please tell me is it mandatory to use, ubuntu 22.4 server version, now i am facing issue to run bench.

you can use ubuntu 20+ versions, kindly share the error you are facing. then only we can traceback

Error on creation:

bench new-site test1.loc
MySQL root password:

Installing frappe…
Updating DocTypes for frappe : [========================================] 100%
Updating country info : [========================================] 100%
Set Administrator password:
Re-enter Administrator password:
Please make sure that Redis Queue runs @ redis://localhost:11000
Please make sure that Redis Queue runs @ redis://localhost:11000
Please make sure that Redis Queue runs @ redis://localhost:11000
Please make sure that Redis Queue runs @ redis://localhost:11000
Please make sure that Redis Queue runs @ redis://localhost:11000
Please make sure that Redis Queue runs @ redis://localhost:11000
Please make sure that Redis Queue runs @ redis://localhost:11000
Please make sure that Redis Queue runs @ redis://localhost:11000
Please make sure that Redis Queue runs @ redis://localhost:11000
Please make sure that Redis Queue runs @ redis://localhost:11000
Traceback (most recent call last):
File “/home/frappe/f14/apps/frappe/frappe/model/base_document.py”, line 502, in db_insert
frappe.db.sql(
File “/home/frappe/f14/apps/frappe/frappe/database/database.py”, line 221, in sql
self._cursor.execute(query, values)
File “/home/frappe/f14/env/lib/python3.10/site-packages/pymysql/cursors.py”, line 158, in execute
result = self._query(query)
File “/home/frappe/f14/env/lib/python3.10/site-packages/pymysql/cursors.py”, line 325, in _query
conn.query(q)
File “/home/frappe/f14/env/lib/python3.10/site-packages/pymysql/connections.py”, line 549, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File “/home/frappe/f14/env/lib/python3.10/site-packages/pymysql/connections.py”, line 779, in _read_query_result
result.read()
File “/home/frappe/f14/env/lib/python3.10/site-packages/pymysql/connections.py”, line 1157, in read
first_packet = self.connection._read_packet()
File “/home/frappe/f14/env/lib/python3.10/site-packages/pymysql/connections.py”, line 729, in _read_packet
packet.raise_for_error()
File “/home/frappe/f14/env/lib/python3.10/site-packages/pymysql/protocol.py”, line 221, in raise_for_error
err.raise_mysql_exception(self._data)
File “/home/frappe/f14/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 ‘email_account.pull’ for key ‘PRIMARY’”)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/frappe/f14/apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py”, line 209, in insert_single_event
doc.insert()
File “/home/frappe/f14/apps/frappe/frappe/model/document.py”, line 270, in insert
self.db_insert(ignore_if_duplicate=ignore_if_duplicate)
File “/home/frappe/f14/apps/frappe/frappe/model/base_document.py”, line 529, in db_insert
raise frappe.DuplicateEntryError(self.doctype, self.name, e)
frappe.exceptions.DuplicateEntryError: (‘Scheduled Job Type’, ‘email_account.pull’, IntegrityError(1062, “Duplicate entry ‘email_account.pull’ for key ‘PRIMARY’”))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/frappe/f14/env/lib/python3.10/site-packages/redis/connection.py”, line 559, in connect
sock = self._connect()
File “/home/frappe/f14/env/lib/python3.10/site-packages/redis/connection.py”, line 615, in _connect
raise err
File “/home/frappe/f14/env/lib/python3.10/site-packages/redis/connection.py”, line 603, in _connect
sock.connect(socket_address)
OSError: [Errno 99] Cannot assign requested address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/frappe/f14/env/lib/python3.10/site-packages/tenacity/init.py”, line 407, in call
result = fn(*args, **kwargs)
File “/home/frappe/f14/apps/frappe/frappe/utils/background_jobs.py”, line 380, in get_redis_conn
redis_connection = RedisQueue.get_connection(**cred)
File “/home/frappe/f14/apps/frappe/frappe/utils/redis_queue.py”, line 24, in get_connection
conn.ping()
File “/home/frappe/f14/env/lib/python3.10/site-packages/redis/client.py”, line 1378, in ping
return self.execute_command(‘PING’)
File “/home/frappe/f14/env/lib/python3.10/site-packages/redis/client.py”, line 898, in execute_command
conn = self.connection or pool.get_connection(command_name, **options)
File “/home/frappe/f14/env/lib/python3.10/site-packages/redis/connection.py”, line 1192, in get_connection
connection.connect()
File “/home/frappe/f14/env/lib/python3.10/site-packages/redis/connection.py”, line 563, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 99 connecting to localhost:11000. Cannot assign requested address.

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

Traceback (most recent call last):
File “/usr/lib/python3.10/runpy.py”, line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File “/usr/lib/python3.10/runpy.py”, line 86, in _run_code
exec(code, run_globals)
File “/home/frappe/f14/apps/frappe/frappe/utils/bench_helper.py”, line 109, in
main()
File “/home/frappe/f14/apps/frappe/frappe/utils/bench_helper.py”, line 18, in main
click.Group(commands=commands)(prog_name=“bench”)
File “/home/frappe/f14/env/lib/python3.10/site-packages/click/core.py”, line 829, in call
return self.main(*args, **kwargs)
File “/home/frappe/f14/env/lib/python3.10/site-packages/click/core.py”, line 782, in main
rv = self.invoke(ctx)
File “/home/frappe/f14/env/lib/python3.10/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/f14/env/lib/python3.10/site-packages/click/core.py”, line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/frappe/f14/env/lib/python3.10/site-packages/click/core.py”, line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/frappe/f14/env/lib/python3.10/site-packages/click/core.py”, line 610, in invoke
return callback(*args, **kwargs)
File “/home/frappe/f14/apps/frappe/frappe/commands/site.py”, line 77, in new_site
_new_site(
File “/home/frappe/f14/apps/frappe/frappe/installer.py”, line 106, in _new_site
install_app(app, verbose=verbose, set_as_patched=not source_sql, force=False)
File “/home/frappe/f14/apps/frappe/frappe/installer.py”, line 306, in install_app
sync_jobs()
File “/home/frappe/f14/apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py”, line 152, in sync_jobs
all_events = insert_events(scheduler_events)
File “/home/frappe/f14/apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py”, line 164, in insert_events
event_jobs += insert_event_jobs(events, event_type)
File “/home/frappe/f14/apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py”, line 182, in insert_event_jobs
insert_single_event(frequency, event)
File “/home/frappe/f14/apps/frappe/frappe/core/doctype/scheduled_job_type/scheduled_job_type.py”, line 212, in insert_single_event
doc.delete()
File “/home/frappe/f14/apps/frappe/frappe/model/document.py”, line 1021, in delete
return frappe.delete_doc(
File “/home/frappe/f14/apps/frappe/frappe/init.py”, line 1244, in delete_doc
return frappe.model.delete_doc.delete_doc(
File “/home/frappe/f14/apps/frappe/frappe/model/delete_doc.py”, line 129, in delete_doc
frappe.enqueue(
File “/home/frappe/f14/apps/frappe/frappe/init.py”, line 2167, in enqueue
return frappe.utils.background_jobs.enqueue(*args, **kwargs)
File “/home/frappe/f14/apps/frappe/frappe/utils/background_jobs.py”, line 101, in enqueue
q = get_queue(queue, is_async=is_async)
File “/home/frappe/f14/apps/frappe/frappe/utils/background_jobs.py”, line 342, in get_queue
return Queue(generate_qname(qtype), connection=get_redis_conn(), is_async=is_async)
File “/home/frappe/f14/env/lib/python3.10/site-packages/tenacity/init.py”, line 324, in wrapped_f
return self(f, *args, **kw)
File “/home/frappe/f14/env/lib/python3.10/site-packages/tenacity/init.py”, line 404, in call
do = self.iter(retry_state=retry_state)
File “/home/frappe/f14/env/lib/python3.10/site-packages/tenacity/init.py”, line 361, in iter
raise retry_exc from fut.exception()
tenacity.RetryError: RetryError[<Future at 0x7f425a5a01f0 state=finished raised ConnectionError>]

Hi @shashank_shirke , thank you for this tutorial.

I was trying to set this up on an Ubuntu EC2 instance and everything worked just fine. However, when I go onto my public IP on port 80, it shows the error "No module named 'erpnext' " along with a bunch of traceback error calls. I am running python 3.10.6 and also tried using bench setup requirements to upgrade any dependencies but it does not seem to work. Could you help with this?

@sinupeniel Did you start the bench before doing this? If not then - cd to frapp-bench and then run the command bench start. This should setup a redis server and other dependencies. Do not close this terminal. Open a new terminal and then run the bench new-site test1.loc.

@tushar-badhwar Try this script:

No hassles installer for ERPNext.

3 Likes

I am new in Frappe and Ubuntu, that’s why I am confused.

1.3 Update & upgrade server packages

sudo apt-get update -y
sudo apt-get upgrade -y

Q 1 : Here in Step 1.3 command is executing from root user then why sudo added before command?

Q 2 : Here in Step 1.4 This command is with dash or without dash?
su - [frappe-user]
because in both cases pwd is different.

Q 3 : In this whole guide, can we use only apt for updating and installing packages?

Q 4 : To get ERPNext successfully configured, Is it compulsory to use [frappe-user] to execute all commands from Step 2 to Step 7?

If you’re running the commands as root user then you can skip adding sudo. But remember at some point you will need to switch to the non-root user to avoid permission issues when you get to the part of installing Frappe apps.

The command is with dash

You can use apt for installing packages but there are some packages you need to install with pip3 and these are Frappe-specific packages

Yes and this is VERY IMPORTANT to avoid permission issues. The frappe user here refers to a non-root user with sudo permissions. As soon as actual frappe app installation starts, you abandon sudo altogether.

Lastly, you can use the no-interactive script mentioned in my earlier reply to install the app if you’re facing challenges with the manual method. You can install development or production with the script with minimal inputs.

Hope this helps.

2 Likes

I followed the exact steps as mentioned, but I am getting below error while creating new site

This error is pretty new but it appears to be harmless at this point as a few have reported no adverse effect to ignoring the error and continuing with the installation. However, if you wish to avoid this error in future install, run the following command just before creating your site and installing ERPNext in the site:

sudo sed -i '/port 6379/a port 11000' /etc/redis/redis.conf
sudo service redis-server restart

This will add the required port to your Redis Server config. Once your site installation is complete and ERPNext is installed, run this command to remove it as it doesn’t seem to be needed afterwards and can even throw errors when installing other apps:

sudo sed -i '/port 11000/d' /etc/redis/redis.conf
sudo service redis-server restart

Hope this helps.

NB: You can use the auto install script mentioned above if you’re having difficulties with manual installation as the script also handles this error as well as helping you install ERPNext with minimal effort.

3 Likes

After adding these lines to my.cnf, do we require to add ERPNext’s official configuration template in /etc/mysql/mariadb.conf.d/mariadb.cnf

after successful installation I found the Nginx server is stopping and resuming randomly, and when it stops I use $bench setup nginx, and it starts working okay,
while I can’t access it, when I see the status of the services, I found everything working okay
$sudo supervisorctl

frappe-bench-redis:frappe-bench-redis-cache RUNNING pid 912, uptime
frappe-bench-redis:frappe-bench-redis-queue RUNNING pid 913, uptime
frappe-bench-redis:frappe-bench-redis-socketio RUNNING pid 915, uptime
frappe-bench-web:frappe-bench-frappe-web RUNNING pid 916, uptime
frappe-bench-web:frappe-bench-node-socketio RUNNING pid 918,
frappe-bench-workers:frappe-bench-frappe-default-worker-0 RUNNING pid 920,
frappe-bench-workers:frappe-bench-frappe-long-worker-0 RUNNING pid 926,
frappe-bench-workers:frappe-bench-frappe-schedule RUNNING pid 919,
frappe-bench-workers:frappe-bench-frappe-short-worker-0 RUNNING pid 921,

any clue ??

Have you checked the log files?

Hello, Mr. cphoa28. Did you found any solution for this?

this is super helpful! thank you!

@flexy2ky this script is working just fine for all V14 installations but I wanted to ask you which edits need to be made for a V13 installation.