Installing new custom app

Hi,
I created a new custom app using bench new-app and gave all details. A folder(appname) gets created under frappe-bench/apps and the appname also gets listed in sites/apps.txt.

On trying to install using bench install-app , I get

“ImportrError: No module named appname.hooks”

I ran these from frappe-bench folder. What else could be the problem?

Thanks
Krithi

@krithi_ramani
Use below syntax:

bench install-app appname

1 Like

Yes, that’s the command I ran. Missed appname in my post

Did you use the command:
bench use app_name
before installing the app, if no, please do it first and if yes then please let us know all the steps you followed.

I had used the following earlier :
bench use
bench --site install-app

this had given the same “Import error:No module named appname.hooks”.

I just now tried
bench use and
bench install-app

I get “TypeError: connect() argument 2 must be string, not None”…

Traceback (most recent call last):
File “/usr/lib/python2.7/runpy.py”, line 162, 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/krithi/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 79, in
main()
File “/home/krithi/frappe-bench/apps/frappe/frappe/utils/bench_helper.py”, line 16, in main
click.Group(commands=commands)(prog_name=‘bench’)
File “/home/krithi/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/home/krithi/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/home/krithi/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/krithi/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/krithi/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/krithi/frappe-bench/env/local/lib/python2.7/site-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/krithi/frappe-bench/env/local/lib/python2.7/site-packages/click/decorators.py”, line 16, in new_func
return f(get_current_context(), *args, **kwargs)
File “/home/krithi/frappe-bench/apps/frappe/frappe/commands.py”, line 29, in _func
ret = f(frappe._dict(ctx.obj), *args, **kwargs)
File “/home/krithi/frappe-bench/apps/frappe/frappe/commands.py”, line 164, in install_app
_install_app(app, verbose=context.verbose)
File “/home/krithi/frappe-bench/apps/frappe/frappe/installer.py”, line 92, in install_app
frappe.clear_cache()
File “/home/krithi/frappe-bench/apps/frappe/frappe/init.py”, line 414, in clear_cache
for fn in frappe.get_hooks(“clear_cache”):
File “/home/krithi/frappe-bench/apps/frappe/frappe/init.py”, line 687, in get_hooks
hooks = _dict(cache().get_value(“app_hooks”, load_app_hooks))
File “/home/krithi/frappe-bench/apps/frappe/frappe/utils/redis_wrapper.py”, line 47, in get_value
val = generator()
File “/home/krithi/frappe-bench/apps/frappe/frappe/init.py”, line 655, in load_app_hooks
for app in [app_name] if app_name else get_installed_apps(sort=True):
File “/home/krithi/frappe-bench/apps/frappe/frappe/init.py”, line 640, in get_installed_apps
installed = json.loads(db.get_global(“installed_apps”) or “[]”)
File “/home/krithi/frappe-bench/apps/frappe/frappe/database.py”, line 641, in get_global
return self.get_default(key, user)
File “/home/krithi/frappe-bench/apps/frappe/frappe/database.py”, line 653, in get_default
d = frappe.defaults.get_defaults(parent).get(key)
File “/home/krithi/frappe-bench/apps/frappe/frappe/defaults.py”, line 49, in get_defaults
globald = get_defaults_for()
File “/home/krithi/frappe-bench/apps/frappe/frappe/defaults.py”, line 154, in get_defaults_for
where parent = %s order by creation""", (parent,), as_dict=1)
File “/home/krithi/frappe-bench/apps/frappe/frappe/database.py”, line 105, in sql
self.connect()
File “/home/krithi/frappe-bench/apps/frappe/frappe/database.py”, line 51, in connect
use_unicode=True, charset=‘utf8’)
File “/home/krithi/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/init.py”, line 81, in Connect
return Connection(*args, **kwargs)
File “/home/krithi/frappe-bench/env/local/lib/python2.7/site-packages/MySQLdb/connections.py”, line 193, in init
super(Connection, self).init(*args, **kwargs2)
TypeError: connect() argument 2 must be string, not None

After using bench use , on bench start, my page too is not getting displayed!!!

I get 404 Not found !

HELP!!

use the following command first:
bench use app_name
then
bench restart
then
bench install-app app_name

What is this now?

krithi@ubuntu:~/frappe-bench$ bench restart
error: <class ‘xmlrpclib.Fault’>, <Fault 10: ‘BAD_NAME: frappe’>: file: /usr/lib/python2.7/xmlrpclib.py line: 794
Traceback (most recent call last):
File “/usr/local/bin/bench”, line 9, in
load_entry_point(‘bench==0.92’, ‘console_scripts’, ‘bench’)()
File “/home/krithi/bench-repo/bench/cli.py”, line 60, in cli
bench()
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 700, in call
return self.main(*args, **kwargs)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 680, in main
rv = self.invoke(ctx)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 1027, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 873, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/usr/local/lib/python2.7/dist-packages/click/core.py”, line 508, in invoke
return callback(*args, **kwargs)
File “/home/krithi/bench-repo/bench/cli.py”, line 297, in restart
restart_supervisor_processes()
File “/home/krithi/bench-repo/bench/utils.py”, line 303, in restart_supervisor_processes
exec_cmd(cmd, cwd=bench)
File “/home/krithi/bench-repo/bench/utils.py”, line 104, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: sudo supervisorctl restart frappe:

It seems like your installation is not done well.

I’ve been using it for a while now, without any issues. Any possibility of getting this corrected?

You are not running this from the frappe-bench folder

1 Like

please check the trace I have pasted…I did run it from frappe-bench

@rmehta I’m facing the same error - I was able to install new app before (before the last big update (in which Document management was launched)…/any ideas?

huh…maybe it’s me.The name of the app I give in ‘bench new-app’ and ‘bench install-app’ commands is different from what the system is looking for. For eg - If I want a new app called ‘Help Desk’, I say bench new-app help-desk and bench install-app help-desk. But the system is looking for help_desk to import. And hence the errors that I faced…if i create an app as help_desk or just ‘helpdesk’, there is no problem.

maybe - there are standards on how the apps should be named and I’m not following it properly?

This is very subtle, and I was stuck on it for hours…adding the info here so that someone else facing the same issue can benefit.

3 Likes

Thanks Kirthi!