URGENT: bench update --patch returns OSError: [Errno 2] No such file or directory

At this moment the erpnext is not working being stuck on sorry! we will be back soon

The error I receive when trying to do a bench update --patch is:

frappe@server2:~/frappe-bench$ bench update --patch
Backing up sites...
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/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 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-repo/bench/commands/update.py", line 61, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, restart_systemd, requirements, no_backup, force=force, reset=reset)
  File "/home/frappe/bench-repo/bench/commands/update.py", line 78, in _update
    backup_all_sites(bench_path=bench_path)
  File "/home/frappe/bench-repo/bench/utils.py", line 517, in backup_all_sites
    backup_site(site, bench_path=bench_path)
  File "/home/frappe/bench-repo/bench/utils.py", line 513, in backup_site
    run_frappe_cmd('--site', site, 'backup', bench_path=bench_path)
  File "/home/frappe/bench-repo/bench/utils.py", line 609, in run_frappe_cmd
    cwd=sites_dir, stdout=stdout, stderr=stderr)
  File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1259, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
frappe@server2:~/frappe-bench$ ls -l

Your assistance will be greatly appreciated.

So it seems that suddenly frappe cannot see python anymore ?

Any idea what to do ?

frappe@server2:~/frappe-bench$ bench update
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Already up-to-date.
INFO:bench.utils:./env/bin/pip install Pillow
/bin/sh: 1: ./env/bin/pip: not found
Please install these dependencies using the command:
sudo apt-get install -y libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/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 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-repo/bench/commands/update.py", line 61, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, restart_systemd, requirements, no_backup, force=force, reset=reset)
  File "/home/frappe/bench-repo/bench/commands/update.py", line 71, in _update
    before_update(bench_path=bench_path, requirements=requirements)
  File "/home/frappe/bench-repo/bench/utils.py", line 755, in before_update
    validate_pillow_dependencies(bench_path, requirements)
  File "/home/frappe/bench-repo/bench/utils.py", line 763, in validate_pillow_dependencies
    exec_cmd("{pip} install Pillow".format(pip=pip))
  File "/home/frappe/bench-repo/bench/utils.py", line 161, in exec_cmd
    raise CommandFailedError(cmd)
bench.utils.CommandFailedError: ./env/bin/pip install Pillow
frappe@server2:~/frappe-bench$

Most likely scenario is that one of the updates was run as root user, and the permissions have now been taken over by the root user. You will need to go to the ~/frappe-bench subdir, and run…

cd ~/frappe-bench
sudo chown -R frappe:frappe ./*

Yeah, most likely scenario but unfortunate after using the chown the problem is the same:

frappe@server2:~/frappe-bench$ bench update
INFO:bench.utils:updating bench
INFO:bench.utils:git pull
Already up-to-date.
INFO:bench.utils:./env/bin/pip install Pillow
/bin/sh: 1: ./env/bin/pip: not found
Please install these dependencies using the command:
sudo apt-get install -y libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 11, in <module>
    load_entry_point('bench', 'console_scripts', 'bench')()
  File "/home/frappe/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 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-repo/bench/commands/update.py", line 61, in update
    _update(pull, patch, build, bench, auto, restart_supervisor, restart_systemd, requirements, no_backup, force=force, reset=reset)
  File "/home/frappe/bench-repo/bench/commands/update.py", line 71, in _update
    before_update(bench_path=bench_path, requirements=requirements)
  File "/home/frappe/bench-repo/bench/utils.py", line 755, in before_update
    validate_pillow_dependencies(bench_path, requirements)
  File "/home/frappe/bench-repo/bench/utils.py", line 763, in validate_pillow_dependencies
    exec_cmd("{pip} install Pillow".format(pip=pip))
  File "/home/frappe/bench-repo/bench/utils.py", line 161, in exec_cmd
    raise CommandFailedError(cmd)
bench.utils.CommandFailedError: ./env/bin/pip install Pillow
frappe@server2:~/frappe-bench$

I don’t know how I fixed it. But I did

The issue was that I wanted to migrate the env to python3 - for some reason it doesn’t work.

Ultimately even migrating back to python2 it didn’t work … anyway, it’s solved.

1 Like

Did you remember how you fixed the issue?

sometimes bench install doesn’t export the path to the ~/.bashrc file

so running this in the terminal will work

export PATH=$PATH:~/.local/bin

and if this repeat again, add this line to the ~/.bashrc file and source it

sometimes it will also need a reboot to reflect