Try ERPNext Buy Support Partners Foundation

Error On Bench Setup Production command

Hello Everyone, I am trying to create a new site on a new instance of bench for production using AWS RDS as a database.
I have followed the steps outlined here in the Hitchhiker’s guide to installing Frappe
First, I installed git with the command

sudo apt-get install git
then I installed python3 and setuptools with the command

sudo apt-get install python3-setuptools python3-pip

I installed Redis, node, and yarn with the commands
sudo apt-get install redis-server

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

sudo npm install -g yarn

I was already a non-root user so no need to create one, also, I did not need to install MySQL since I am using AWS RDS.
then, I installed bench with the command

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

I created a bench instance with the command

bench init --frappe-branch version-12 frappe-bench
sudo -H python -m pip install frappe-bench

To ensure python loads frappe properly I ran the command

./env/bin/pip3 install -e apps/frappe/

I changed directory to the sites folder in frappe-bench and edited common_site_config.json to include the hostname of the RDS instance
I created a site with the command

bench new-site sitename

I successfully added all the necessary apps for the instance using the command

bench get-app remote-url
I also ran ./env/bin/pip3 install -e apps/erpnext/ to ensure ERPNext loads properly

I created a new site (which installed frappe by default) with the command
bench new-site sitename

I proceeded to install all the necessary apps without issue with the command
bench --site sitename install-app app

I setup Nginx and Supervisor by running

sudo apt-get install Nginx
bench setup Nginx
rm -f /etc/nginx/sites-enabled/*
sudo ln -s ./config/nginx.conf /etc/nginx/sites-enabled/frappe.conf
sudo ln -s /home/my_user_id/my_bench_folder/config/nginx.conf /etc/nginx/sites-enabled/frappe.conf
sudo service nginx restart

and

sudo apt-get install supervisor

my error appears when i run the command

sudo bench setup production ubuntu

/home/ubuntu/.local/lib/python2.7/site-packages/pkg_resources/py2_warn.py:21: UserWarning: Setuptools will stop working on Python 2
************************************************************
You are running Setuptools on Python 2, which is no longer
supported and
>>> SETUPTOOLS WILL STOP WORKING <<<
in a subsequent release (no sooner than 2020-04-20).
Please ensure you are installing
Setuptools using pip 9.x or later or pin to `setuptools<45`
in your environment.
If you have done those things and are still encountering
this message, please follow up at
https://bit.ly/setuptools-py2-warning.
************************************************************
  sys.version_info < (3,) and warnings.warn(pre + "*" * 60 + msg + "*" * 60)
frappe-bench-redis: disappeared
frappe-bench-web: disappeared
frappe-bench-workers: disappeared
$ sudo /usr/bin/supervisorctl update
/home/ubuntu/.local/lib/python2.7/site-packages/pkg_resources/py2_warn.py:21: UserWarning: Setuptools will stop working on Python 2
************************************************************
You are running Setuptools on Python 2, which is no longer
supported and
>>> SETUPTOOLS WILL STOP WORKING <<<
in a subsequent release (no sooner than 2020-04-20).
Please ensure you are installing
Setuptools using pip 9.x or later or pin to `setuptools<45`
in your environment.
If you have done those things and are still encountering
this message, please follow up at
https://bit.ly/setuptools-py2-warning.
************************************************************
  sys.version_info < (3,) and warnings.warn(pre + "*" * 60 + msg + "*" * 60)
frappe-bench-workers: stopped
frappe-bench-workers: removed process group
frappe-bench-web: stopped
frappe-bench-web: removed process group
frappe-bench-redis: stopped
frappe-bench-redis: removed process group
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl reload nginx

I have also attempted to install with the easy install script but i got this error

Traceback (most recent call last):
  File "install.py", line 437, in <module>
    install_bench(args)
  File "install.py", line 241, in install_bench
    run_playbook('site.yml', sudo=True, extra_vars=extra_vars)
  File "install.py", line 362, in run_playbook
    success = subprocess.check_call(args, cwd=os.path.join(cwd, 'playbooks'), stdout=log_stream, stderr=sys.stderr)
  File "/usr/lib/python3.5/subprocess.py", line 581, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ansible-playbook', '-c', 'local', 'site.yml', '-vvvv', '-e', '@/tmp/extra_vars.json', '--become', '--become-user=frappe']' returned non-zero exit status 2

Please any help will be appreciated.

Try bench migrate-env python3.5 then bench setup production ubuntu , without sudo

I don’t know if the RDS will work or not, and bringing python redis, nodejs and yarn up to date probably wouldn’t hurt.

Thanks for your help, I successfully migrated but I could not run bench setup production without adding the sudo tag.April21_2
Adding the sudo tag raises the same error

DEBUG:bench.utils:Migration Successful to /usr/bin/python3.5
ubuntu@ip-172-31-26-22:~/frappe-bench$ bench setup production ubuntu
WARN: superuser privileges required for this command
ubuntu@ip-172-31-26-22:~/frappe-bench$ sudo bench setup production ubuntu
/home/ubuntu/frappe-bench/env/bin/python: Error while finding spec for 'frappe.utils.bench_helper' (ImportError: No module named 'frappe')

supervisor.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
nginx.conf already exists and this will overwrite it. Do you want to continue? [y/N]: y
Port configuration list:


$ sudo /usr/bin/supervisorctl reread
/home/ubuntu/.local/lib/python2.7/site-packages/pkg_resources/py2_warn.py:21: UserWarning: Setuptools will stop working on Python 2
************************************************************
You are running Setuptools on Python 2, which is no longer
supported and
>>> SETUPTOOLS WILL STOP WORKING <<<
in a subsequent release (no sooner than 2020-04-20).
Please ensure you are installing
Setuptools using pip 9.x or later or pin to `setuptools<45`
in your environment.
If you have done those things and are still encountering
this message, please follow up at
https://bit.ly/setuptools-py2-warning.
************************************************************
  sys.version_info < (3,) and warnings.warn(pre + "*" * 60 + msg + "*" * 60)
No config updates to processes
$ sudo /usr/bin/supervisorctl update
/home/ubuntu/.local/lib/python2.7/site-packages/pkg_resources/py2_warn.py:21: UserWarning: Setuptools will stop working on Python 2
************************************************************
You are running Setuptools on Python 2, which is no longer
supported and
>>> SETUPTOOLS WILL STOP WORKING <<<
in a subsequent release (no sooner than 2020-04-20).
Please ensure you are installing
Setuptools using pip 9.x or later or pin to `setuptools<45`
in your environment.
If you have done those things and are still encountering
this message, please follow up at
https://bit.ly/setuptools-py2-warning.
************************************************************
  sys.version_info < (3,) and warnings.warn(pre + "*" * 60 + msg + "*" * 60)
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
$ sudo systemctl reload nginx

Try this:

from inside your frappe bench directory run the following commands in sequence

  1. source env/bin/activate
  2. pip3 install -e ./apps/frappe --no-cache-dir
  3. bench build
  4. deactivate

Then try to do the bench setup production ubuntu again

Also, on a fresh instance you might want to try the process here:

It seems to be updated install instructions for bench v5