Can't deploy frappe to GCP Compute Engine VM Instance

Hi All,

I have an issue while I try to deploy my frappe and erpnext from my GitHub repo to one of my GCP Compute Engine VM Instance.

The error message showed as below whenever I try to clone the repo to the VM
" File "/usr/lib/python3.5/runpy.py", line 184, in _run_module_as_main",
" "main", mod_spec)“,
" File "/usr/lib/python3.5/runpy.py", line 85, in _run_code”,
" exec(code, run_globals)“,
" File "/home/username/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 97, in ”,
" main()“,
" File "/home/username/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 18, in main”,
" click.Group(commands=commands)(prog_name=‘bench’)“,
" File "/home/username/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 764, in call”,
" return self.main(*args, **kwargs)“,
" File "/home/username/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 717, in main”,
" rv = self.invoke(ctx)“,
" File "/home/username/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 1137, in invoke”,
" return _process_result(sub_ctx.command.invoke(sub_ctx))“,
" File "/home/username/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 1137, in invoke”,
" return _process_result(sub_ctx.command.invoke(sub_ctx))“,
" File "/home/username/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 956, in invoke”,
" return ctx.invoke(self.callback, **ctx.params)“,
" File "/home/username/frappe-bench/env/lib/python3.5/site-packages/click/core.py", line 555, in invoke”,
" return callback(*args, **kwargs)“,
" File "/home/username/frappe-bench/apps/frappe/frappe/commands/site.py", line 32, in new_site”,
" db_type=db_type)“,
" File "/home/username/frappe-bench/apps/frappe/frappe/commands/site.py", line 51, in _new_site”,
" import frappe.utils.scheduler",
" File "/home/username/frappe-bench/apps/frappe/frappe/utils/scheduler.py", line 23, in “,
" from frappe.core.doctype.user.user import STANDARD_USERS”,
" File "/home/username/frappe-bench/apps/frappe/frappe/core/doctype/user/user.py", line 529",
" ret = [ role.get("name") for role in roles ]“,
" ^”,
“TabError: inconsistent use of tabs and spaces in indentation”
],
“stdout”: “”,
“stdout_lines”:
}

PLAY RECAP *******************************************************************************************************************************************************************
localhost : ok=75 changed=18 unreachable=0 failed=1 skipped=64 rescued=0 ignored=0

Traceback (most recent call last):
File “install.py”, line 489, in
install_bench(args)
File “install.py”, line 275, in install_bench
run_playbook(‘site.yml’, sudo=True, extra_vars=extra_vars)
File “install.py”, line 405, in run_playbook
success = subprocess.check_call(args, cwd=playbooks_folder, 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=username’]’ returned non-zero exit status 2

disclaimer: I didn’t touch anything from the user.py file.

FYI I refer to de docs easy installation provided by frappe from their GitHub repo, these are the deployment steps that I did to my VM.

  1. run below command
    apt install python3-minimal build-essential python3-setuptools
    note: from the root directory or frappe
  2. after all installation finished, run the below command
    wget https://raw.githubusercontent.com/frappe/bench/develop/install.py
    note: from the wherever directory
  3. run below command to continue
    sudo pip3 install --upgrade pip
  4. then run below command to setup frappe and erpnext from your repo
    sudo python3 install.py --production --site my-site --user username --frappe-repo-url myfrappe-repo-url.git --erpnext-repo-url myerpnext-repo-url.git --verbose --overwrite --frappe-branch master --erpnext-branch master
    note: if its fail please run this command first before installation sudo pip3 install cryptography

Is there anything that I missed guys? Or can anyone give any insight to solve this issue?
Really appreciate if someone can give some insights or suggestion on how to solve the issue from your experiences.

What Linux version do you have deployed on GPC VM? (anyways, it’s just for reference)
This is an editor problem at your end (or at least so it seems).

Try this on your edited file/s and let us know how it went.

Solution 1:
*install autopep8:
pip install --upgrade autopep8
or
pip install autopep8

*then run pep8 on your file:
autopep8 -i my_file.py

Solution 2:
It’s important to not use tabs at all.
*Set your editor to use 4 spaces for indentation.
*Make a search and replace all tabs with 4 spaces.
*Make sure your editor is set to display tabs as 8 spaces.

@ene_sorin sorry but that’s completely wrong. Frappe / ERPNext uses tabs everywhere and using spaces is not allowed.

Shet, you are right (idk what was I thinking maybe still hangover).
Do you think @stormbreaker must have some spaces lurking around or his charset is not UTF-8 then?

Alternatively, you may try Bitnami deployment from the GCP marketplace. It is a single-click install. Just click “Create Instance”, select “Marketplace” and search for “ERPnext”.

I haven’t used it so can’t comment on the completeness of the Bitnami image.

Hi @ene_sorin, I used Ubuntu LTS 16 for my VM.

You should try LTS 18.04

Erpnext already exist in google marketplace no need to build it from scratch

Hi @ene_sorin, I already tried to deploy to LTS 18.04 as well. But still, the result was the same. Is there any way to fix the indentation? FYI I don’t custom anything from the user.py file. I don’t why it always shows the indentation was wrong.

Hi @SOLOSOFT, I custom some functionality from the erpnext so I can’t just use the erpnext from the marketplace.