Fully Automated Install Script for ERPNext Version 14

UPDATE: Support added for Ubuntu 23.04, 24.04 and Debian 12. Also, ERPNext installation is now optional and added optional install for HRMS.

1 Like

Just tried - everything ran fine until HRMS install.

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/hrm
s/issues/new if not resolved.
An error occurred while installing hrms: Module import failed for Expense Claim Type, the DocType you’re trying to open might be deleted.<br
Error: No module named ‘frappe.core.doctype.expense_claim_type’

Then the script stopped - and the webpage gives:

Uncaught Server Exception

There was an error building this page

Error Code: 404

If you don’t know what just happened, and wish to file a ticket please
copy the error below and share it.

I’ll try it again in a few hours without the HRMS module.

Tried again without HRMS. Ran smoothly and installed no problem.

Ahh - just noticed - instead of a directory “frappe-bench” - it created one named “v14-bench” instead (and I installed ERPNext v15).

My bad. I have reverted the bench directory to the default frappe-bench.

i noticed that HRMS install fails sometimes but its got nothing to do with the script.

1 Like

So it is better to skip HRMS in auto installer and do it manually right?

Yes. Although the failure doesn’t occur every time

Hello @flexy2ky,

it is me again :), i want to install ERPNext by your script, but i get error;

Enter the site name (If you wish to install SSL later, please enter a FQDN): erpnextdemo.local
Enter the Administrator password:
Confirm password:
Password confirmed

Now setting up your site. This might take a few minutes. Please wait...
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/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/site.py", line 68, in new_site
    _new_site(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 87, in _new_site
    install_db(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/installer.py", line 160, in install_db
    setup_database(force, source_sql, verbose, no_mariadb_socket)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/__init__.py", line 21, in setup_database
    return frappe.database.mariadb.setup_db.setup_database(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/setup_db.py", line 31, in setup_database
    if force or (db_name not in dbman.get_database_list()):
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/db_manager.py", line 50, in get_database_list
    return self.db.sql("SHOW DATABASES", pluck=True)
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 211, in sql
    self.connect()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/database.py", line 117, in connect
    self._conn: "MariadbConnection" | "PostgresConnection" = self.get_connection()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 107, in get_connection
    conn = self._get_connection()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 113, in _get_connection
    return self.create_connection()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/database/mariadb/database.py", line 116, in create_connection
    return pymysql.connect(**self.get_connection_settings())
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 361, in __init__
    self.connect()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 669, in connect
    self._request_authentication()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 957, in _request_authentication
    auth_packet = self._read_packet()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/connections.py", line 775, in _read_packet
    packet.raise_for_error()
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/protocol.py", line 219, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "/home/frappe/frappe-bench/env/lib/python3.10/site-packages/pymysql/err.py", line 150, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1698, "Access denied for user 'root'@'localhost'")
An error occurred on line 369 with exit status 0

root had password but i removed it (How to remove root password on Debian? - Unix & Linux Stack Exchange), still gives errors.

1 Like

Hi flex2sky

That Python marker file - /usr/lib/python3.11/EXTERNALLY-MANAGED - or - /usr/lib/python3.12/EXTERNALLY-MANAGED can magically reappear.

Just tried to update Bench in an old production install I did on 23.10 - sudo pip3 install --upgrade frappe-bench - and was surprised to get a “This environment is externally managed”.

Sure enough - in /usr/lib/python3.11 - that EXTERNALLY-MANAGED file is back. Must have been some update (currently Python 3.11.6).

I’ll try this weekend to get your script to run with pipx (instead of removing that file) and let you know how I go.

1 Like

Install worked without a hitch - Ubuntu 24 on AWS EC2. Thanks so much for this script it is very cool :sunglasses:

1 Like

To disable the externally-managed-environment error

sudo python3 -m pip config --global set global.break-system-packages true
2 Likes

Thanks NURAV - that works well. I included it in a copy of this install script - after deleting the bit about “# Check if EXTERNALLY-MANAGED file exists and remove it”.
So the copy I used now looks:

334  # Install bench
335  echo -e "${YELLOW}Now let's install bench${NC}"
336  sleep 2
337
338  sudo python3 -m pip config --global set global.break-system-packages true
339
340  sudo apt install python3-pip -y
341  sudo pip3 install frappe-bench
342
343  # Initiate bench in frappe-bench folder, but get a supervisor can't restart bench error...

Installed to production no problem.

1 Like

@Elkanaaa You could make a pull request so others can benefit from this update if you’ve tested it and it’s working.

1 Like

Hi, does anyone know why I keep getting the following error “An error occurred on line 351 with exit status 0” this happens right after0
yarn run v1.22.22
$ node esbuild --production --run-build-command
Browserslist: caniuse-lite is outdated. Please run:
npx update-browserslist-db@latest
Why you should do it regularly: GitHub - browserslist/update-db: CLI tool to update caniuse-lite to refresh target browsers from Browserslist config

Hi im trying to use the script but have an error, when i restart the VPS, and start again now say

Site erpnext.testsite.com already exists
An error occurred on line 369 with exit status 0

What i need to do to use the same site i put in the first time

Already fixed with this
bench drop-site --no-backup