Bench --site <site> install-app erpnext failure

I have been trying to get erpnext installed on an AWS Ubuntu (18.04) instance.

This is a clean install onto a freshly updated Ubuntu with no other software installed. After the error message below I include my “script” that I am following for the install.

Here is the error I get after making a new site in bench and attempting to add the erpnext module:

ubuntu@ip-xxxx:~/frappe-bench$ bench new-site xxx.xxx
MySQL root password:

Installing frappe...
Updating DocTypes for frappe        : [========================================]
Updating country info               : [========================================]
Set Administrator password:
Re-enter Administrator password:
*** Scheduler is disabled ***
ubuntu@ip-xxxx:~/frappe-bench$ bench --site xxx.xxx install-app erpnext

Installing erpnext...
Updating DocTypes for erpnext       : [============                            ]Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in <module>
    main()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main
    click.Group(commands=commands)(prog_name='bench')
  File "/home/ubuntu/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/ubuntu/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/ubuntu/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/ubuntu/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/ubuntu/frappe-bench/env/lib/python2.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/ubuntu/frappe-bench/env/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/__init__.py", line 25, in _func
    ret = f(frappe._dict(ctx.obj), *args, **kwargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/commands/site.py", line 168, in install_app
    _install_app(app, verbose=context.verbose)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/installer.py", line 145, in install_app
    sync_for(name, force=True, sync_everything=True, verbose=verbose, reset_permissions=True)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/sync.py", line 56, in sync_for
    reset_permissions=reset_permissions, for_sync=True)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 65, in import_file_by_path
    ignore_version=ignore_version, reset_permissions=reset_permissions)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/import_file.py", line 132, in import_doc
    doc.insert()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py", line 249, in insert
    self.run_post_save_methods()
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py", line 905, in run_post_save_methods
    self.run_method("on_update")
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py", line 772, in run_method
    out = Document.hook(fn)(self, *args, **kwargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py", line 1048, in composer
    return composed(self, method, *args, **kwargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py", line 1031, in runner
    add_to_return_value(self, fn(self, *args, **kwargs))
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/document.py", line 766, in <lambda>
    fn = lambda self, *args, **kwargs: getattr(self, method)(*args, **kwargs)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 264, in on_update
    self.run_module_method("on_doctype_update")
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/core/doctype/doctype/doctype.py", line 329, in run_module_method
    module = load_doctype_module(self.name, self.module)
  File "/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/utils.py", line 187, in load_doctype_module
    raise ImportError('Module import failed for {0} ({1})'.format(doctype, module_name + ' Error: ' + str(e)))
ImportError: Module import failed for Email Digest (erpnext.setup.doctype.email_digest.email_digest Error: cannot import name get_link_to_report)
ubuntu@ip-xxxx:~/frappe-bench$

Here is my “script” for installation -

sudo apt-get update
sudo apt-get dist-upgrade

sudo apt-get install git
git --version

sudo apt-get install python3-dev
sudo apt-get install python3-setuptools python3-pip
# despite python 2.7 going EOL soon, it is required.
sudo apt-get install python
sudo apt-get install python-pip python-setuptools
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://ftp.ubuntu-tw.org/mirror/mariadb/repo/10.3/ubuntu xenial main'

sudo apt-get update
# This command will ask you to setup a password - NOTE THIS PASSWORD
sudo apt-get install mariadb-server-10.3

#test the database works - use the password previously supplied
# type /q to quit
mysql -u root -p -h localhost

sudo apt-get install libmysqlclient-dev

echo " " > frappe_my.cnf
echo "[mysqld]" >> frappe_my.cnf
echo "character-set-client-handshake = FALSE" >> frappe_my.cnf
echo "character-set-server = utf8mb4" >> frappe_my.cnf
echo "collation-server = utf8mb4_unicode_ci" >> frappe_my.cnf
echo " " >> frappe_my.cnf
echo "[mysql]" >> frappe_my.cnf
echo "default-character-set = utf8mb4" >> frappe_my.cnf

# THIS SECTION DOESN'T WORK.  The frappe_my.cnf file is not loaded…
# manually added to /etc/mysql/my.cnf
grep -Fq "include /home/ubuntu/frappe_my.cnf" /etc/mysql/my.cnf
if [ $? -gt 0 ]; then
  sudo sh -c 'echo "#Frappe config" >> /etc/mysql/my.cnf'
  sudo sh -c 'echo "!include /home/ubuntu/frappe_my.cnf" >> /etc/mysql/my.cnf'
fi

sudo service mysql restart
sudo apt-get install redis-server

sudo apt-get install curl
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs

sudo npm install -g yarn

git clone https://github.com/frappe/bench
# If the above already exists (Error "fatal: destination path 'bench' already exists and is not an empty directory', 128), then update it.
if [ $? -eq 128 ]; then
  cd bench
  git pull
  cd ..
fi

pip3 install -e ./bench
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi
bench --version


#This may fail with "already exists", this is fine.
if [ ! -d "frappe-bench" ]; then
  # This idiotic workaround fixes an apparent error in first time installs
  bench init frappe-bench
  rm -rdf frappe-bench
  sudo chown -R ubuntu:ubuntu ./config/configstore/*
  bench init frappe-bench
fi

cd ~/frappe-bench
bench switch-to-branch master
bench update --patch


grep -Fq "vm.overcommit_memory = 1" /etc/sysctl.conf
if [ $? -gt 0 ]; then
  sudo sh -c 'echo "vm.overcommit_memory = 1" >> /etc/sysctl.conf'
  sudo sysctl vm.overcommit_memory=1
fi

sudo sh -c 'echo never > /sys/kernel/mm/transparent_hugepage/enabled'
sudo service redis restart
grep -Fq "echo never > /sys/kernel/mm/transparent_hugepage/enabled" /etc/rc.local
if [ $? -gt 0 ]; then
  sudo sh -c 'echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled\nservice redis restart" > /etc/rc.local'
  chmod +x /etc/rc.local
fi

cd ~/frappe-bench
bench get-app erpnext

#bench migrate-env python3
bench switch-to-branch master
bench update
bench config dns_multitenant on

#Use the password previously supplied (MariaDB/MySQL)
# If this fails, you must drop the database before you can retry
#mysql -u root -p
#drop database 90……
bench new-site xxx.xxx

############# TESTED TO HERE #############
# Supply an Administrator password
bench --site xxx.xxx install-app erpnext
#ImportError: Module import failed for Email Digest (erpnext.setup.doctype.email_digest.email_digest Error: cannot import name 'get_link_to_report')

Here is the Explore View. Lots of missing items here.

Seems your frappe and erpnext instances might be on separate (and incompatible) branches. Maybe there needs to be a validation for this.

If I do a simple

git clone https://github.com/frappe/bench
pip install -e ./bench
bench init frappe-bench

Which branch am I on? Master or Develop? Is there a bench command which will tell me?

cd frappe-bench
bench get-app erpnext

Which branch is erpnext on?
How do I force them to be on master (currently v11)?

If you go to apps/frappe and apps/erpnext, the command git status will tell you what branch you’re currently on.

1 Like

OK - so the default is “upstream/develop”.

And I apparently have uncommitted files.

ubuntu@ip-xxx.xxx:~/frappe-bench/apps/erpnext$ git status
On branch develop
Your branch is up to date with 'upstream/develop'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        erpnext/public/node_modules
        patches.txt

nothing added to commit but untracked files present (use "git add" to track)

I’m not sure this is going well.

Hmm…the uncommitted files are odd. You could try git diff to see what has been changed.

Regardless, if you don’t have a site setup yet (and thus not much to risk), it should be easy enough to switch over to master and then force a clean refresh.

bench switch-to-branch master frappe erpnext
bench update --force

I think I’ll go back a few steps to avoid pulling the develop branch in the first place.

bench automatically tracks master, develop, and staging for both frappe and erpnext, so you’re pulling all three no matter which version you install. The only thing the switch-to-branch command does is change which snapshot is active in your file system.

If you’re doing the manual install (and it looks like you are), you’ll start with the develop branch by default, and if you want master you just switch branches. The “easy install” script, on the other hand, gives you an option to choose between the two.

1 Like

Go the same issue! can anyone help me please?