Install requirements with bench problem (ImportError)

help me please to fix my problem.


  • bench 4.1.0
  • erpnext 7.0.53
  • frappe 7.0.39

I have added new library to requirements.txt

Why bench doesn’t not install my library during setup?

Not help me restart and some other stuff like:
bench restart
bench build
bench switch-to-master --upgrade
bench migrate
bench clear-cache
bench clear-website-cache

Always Import error


please check following thread How to install 3rd party libraries or sdks into the application - #2 by makarand_b.

Thanks, Makarand

Nothing helps me. This not resolve my problem:

try bench update --requirement
~frappe-bench/env/bin/pip install -r apps/your_app/requirements.txt

As example:



Setup everything on clean environment

bench get-app custom_application
bench --site erpnext.vm install-app custom_application
bench restart

And verify that my lib was installed:

frappe@erpnext:~/frappe-bench$ python
Python 2.7.6 (default, Jun 22 2015, 18:00:18)
[GCC 4.8.2] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
import colorama
Traceback (most recent call last):
File “”, line 1, in
ImportError: No module named colorama

ERROR :frowning:

I found interesting thing that it works in this way:

frappe@erpnext:~/frappe-bench$ bench shell
frappe@erpnext:~/frappe-bench/sites$ python
Python 2.7.6 (default, Jun 22 2015, 18:00:18)
[GCC 4.8.2] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.
import colorama
from colorama import init

OK! Works!

But why I see on my site error with import

how to fix this I don’t know:

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 55, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 19, in handle
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 30, in execute_cmd
method = get_attr(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 114, in get_attr
method = frappe.get_attr(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 859, in get_attr
return getattr(get_module(modulename), methodname)
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 643, in get_module
return importlib.import_module(modulename)
File “/usr/lib/python2.7/importlib/”, line 37, in import_module
File “/home/frappe/frappe-bench/apps/custom_application/custom_application/”, line 11, in
from colorama import init
ImportError: No module named colorama

@rmehta: may I ask you to help to investigate this issue on your end as well? This is going to be a real blocker on our end soon.


Hi Guys!

I was taking a look at this issue. Looks like frappe’s sandbox is broken for some third party modules. Here is are two example:

  1. Colorama module:
from colorama import init <--- this causes import error

but this works:

colorama = frappe.get_module("colorama")
  1. with fedex module from: fedex · PyPI

Same issue:

from import FedexTrackRequest <--- error module not found
from fedex.config import FedexConfig <--- error module not found

But this works:

fedex_track_service = frappe.get_module("")
fedex_config = frappe.get_module("fedex.config")
FedexTrackRequest = fedex_track_service.FedexTrackRequest
FedexConfig = fedex_config.FedexConfig

Seems like the sandbox import path is broken to me on certain modules. I found similar reports for django’s sandbox and colorama.

Still not completely sure how to go about debugging this though.


To test the python console:

bench --site yoursite console

Bench python runs in a virtualenv, to use pip:

env/bin/pip install colorama

Traceback (most recent call last):
File “/home/naztech/.local/bin/bench”, line 11, in
load_entry_point(‘bench’, ‘console_scripts’, ‘bench’)()
File “/home/naztech/bench/bench/”, line 40, in cli
File “/home/naztech/.local/lib/python2.7/site-packages/click/”, line 764, in call
return self.main(*args, **kwargs)
File “/home/naztech/.local/lib/python2.7/site-packages/click/”, line 717, in main
rv = self.invoke(ctx)
File “/home/naztech/.local/lib/python2.7/site-packages/click/”, line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File “/home/naztech/.local/lib/python2.7/site-packages/click/”, line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File “/home/naztech/.local/lib/python2.7/site-packages/click/”, line 555, in invoke
return callback(*args, **kwargs)
File “/home/naztech/bench/bench/commands/”, line 138, in switch_to_branch
switch_to_branch(branch=branch, apps=list(apps), upgrade=upgrade)
File “/home/naztech/bench/bench/”, line 397, in switch_to_branch
switch_branch(branch, apps=apps, bench_path=bench_path, upgrade=upgrade)
File “/home/naztech/bench/bench/”, line 383, in switch_branch
File “/home/naztech/bench/bench/”, line 443, in update_requirements
install_app(app, bench_path=bench_path)
File “/home/naztech/bench/bench/”, line 172, in install_app
File “/home/naztech/bench/bench/”, line 161, in exec_cmd
raise CommandFailedError(cmd)
bench.utils.CommandFailedError: ./env/bin/pip install -q -e ./apps/erpnext