ImportError: No module named psutil

In-short, psutil python module is required for Bench is missing.

Error Log:

Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/.bench/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/.bench/bench/commands/setup.py", line 84, in setup_letsencrypt
    setup_letsencrypt(site, bench_path='.')
  File "/home/frappe/.bench/bench/config/lets_encrypt.py", line 25, in setup_letsencrypt
    run_certbot_and_setup_ssl(site, bench_path)
  File "/home/frappe/.bench/bench/config/lets_encrypt.py", line 55, in run_certbot_and_setup_ssl
    make_nginx_conf(bench_path)
  File "/home/frappe/.bench/bench/config/nginx.py", line 26, in make_nginx_conf
    "limit_conn_shared_memory": get_limit_conn_shared_memory(),
  File "/home/frappe/.bench/bench/config/nginx.py", line 167, in get_limit_conn_shared_memory
    import psutil
ImportError: No module named psutil

Solution 1:

$ su - frappe
# Assuming you are logged in as frappe or equivalent user who have access to Bench / Frappe / ERPNext
$ cd frappe-bench/
$ source env/bin/activate
$ pip install --upgrade psutil

Note: If above does not solves your issue, then do following to fix it:
Solution 2:

# Assuming you are logged in as root or equivalent user who have access to sudo
$ sudo pip install --upgrade psutil
4 Likes

Hi,

While I tried running a bench update --upgrade on one of the client machines, I got this following error. Looks like the upgrade got completed but ended up with this error.

Your bench was upgraded to version 7
supervisor.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==0.92', 'console_scripts', 'bench')()
  File "/home/ubuntu/bench-repo/bench/cli.py", line 40, in cli
    bench_command()
  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/ubuntu/bench-repo/bench/commands/update.py", line 60, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, requirements, no_backup, upgrade, force=force)
  File "/home/ubuntu/bench-repo/bench/commands/update.py", line 94, in _update
    post_upgrade(version_upgrade[1], version_upgrade[2], bench_path=bench_path)
  File "/home/ubuntu/bench-repo/bench/utils.py", line 500, in post_upgrade
    make_nginx_conf(bench_path=bench_path)
  File "/home/ubuntu/bench-repo/bench/config/nginx.py", line 26, in make_nginx_conf
    "limit_conn_shared_memory": get_limit_conn_shared_memory(),
  File "/home/ubuntu/bench-repo/bench/config/nginx.py", line 167, in get_limit_conn_shared_memory
    import psutil
ImportError: No module named psutil

Can you please let me know how to resolve this error?

Thanks
Uma

Had the same issue and resolved it with:

sudo pip install --upgrade psutil

1 Like

Thanks… This helped… My update went through.

Hi Experts,

Im trying to add another site and app to my server - self hosted on digital ocean. I have created the site and app successfully and installed to the site successfully, but when I try to run : bench setup nginx I get this error:

hemant@VarmaniHQ:~/frappe-bench$ bench setup nginx
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 9, in <module>
    load_entry_point('bench==2.0.0', 'console_scripts', 'bench')()
  File "/home/hemant/bench-repo/bench/cli.py", line 40, in cli
    bench_command()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 1060, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/hemant/bench-repo/bench/commands/setup.py", line 22, in setup_nginx
    make_nginx_conf(bench_path=".", yes=yes)
  File "/home/hemant/bench-repo/bench/config/nginx.py", line 26, in make_nginx_conf
    "limit_conn_shared_memory": get_limit_conn_shared_memory(),
  File "/home/hemant/bench-repo/bench/config/nginx.py", line 167, in get_limit_conn_shared_memory
    import psutil
ImportError: No module named psutil

Am I missing something - I tried this on my VM and all worked out fine. So not sure what I done wrong.

Im running v7

Anyone with some feedback will be greatly appreciated.

regards
Hemant

Hi, just run

pip install psutil

1 Like

lol, that simple, thanks vjFalk, worked fine now.

2 Likes