Try ERPNext Buy Support Partners Foundation

SyntaxError in update to ERNext 12.9.2 but seems to work

Just wondering if the following “SyntaxErrors” are an issue. I will file a PR if appropriate.

Cheers,
Dale

frappe@ubuntu:~/frappe-bench$ bench update
remote: Enumerating objects: 480, done.
remote: Counting objects: 100% (480/480), done.
<snip>
Generating Website Theme Files...
Compiling Python Files...
Compiling ../apps/frappe/frappe/integrations/frappe_providers/frappecloud.py ...
  File "../apps/frappe/frappe/integrations/frappe_providers/frappecloud.py", line 199
    print("Uploading files ({}/3)".format(x+1), end="\r")
                                                   ^
SyntaxError: invalid syntax

Compiling ../apps/frappe/frappe/utils/commands.py ...
  File "../apps/frappe/frappe/utils/commands.py", line 11
    req = requests.get(f"https://api.github.com/users/{org}/repos", {"type": "sources", "per_page": 200})
                                                                 ^
SyntaxError: invalid syntax

$ bench build
yarn run v1.16.0
<snip>

Hi Dale,

Did you manage to find a solution for the “request.get” error. I’m also getting a similar error when trying to run bench update or bench update --patch.

My DB was originally a V11 which I forced restored to V12. everything went smoothly. I can even access the system, but I keep getting this error when I run an update.

:~/frappe-bench$ bench update --patch
Backing up sites…
Patching sites…
Migrating site1.local
Updating DocTypes for frappe : [========================================]
Updating DocTypes for erpnext : [========================================]
Updating customizations for Address
Generating Website Theme Files…
Compiling Python Files…
*** Error compiling ‘…/apps/frappe/frappe/utils/commands.py’…
File “…/apps/frappe/frappe/utils/commands.py”, line 11
req = requests.get(f"https://api.github.com/users/{org}/repos", {“type”: “sources”, “per_page”: 200})
^
SyntaxError: invalid syntax

$ sudo supervisorctl restart frappe-bench-workers: frappe-bench-web:
frappe-bench-workers:frappe-bench-frappe-schedule: stopped
frappe-bench-workers:frappe-bench-frappe-default-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-long-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-short-worker-0: stopped
frappe-bench-web:frappe-bench-node-socketio: stopped
frappe-bench-web:frappe-bench-frappe-web: stopped
frappe-bench-workers:frappe-bench-frappe-schedule: started
frappe-bench-workers:frappe-bench-frappe-default-worker-0: started
frappe-bench-workers:frappe-bench-frappe-long-worker-0: started
frappe-bench-workers:frappe-bench-frappe-short-worker-0: started
frappe-bench-web:frappe-bench-frappe-web: started
frappe-bench-web:frappe-bench-node-socketio: started

Thanks.

Hi Dale,

I think I figured out the problem.

  1. open the file in nano …/apps/frappe/frappe/utils/commands.py
  2. Delete the syntax error ‘f’ as shown in the image below

    3.Save and exit
  3. go to the frappe-bench directory and run $bench update --patch

Worked for me.

Thanks @Max3 for your suggestion but it seems the issue goes deeper. I don’t understand “f-strings” but at first view the “f” does seem to be a typo. However, after editing as you suggest I’m getting a similar error in another file.

@clarkej has suggested this is because the server is still using Python 2 instead of Python 3 (I started with the vm download from erpnext.com which at the time of downloaded was Python 2 if not still), and referenced http://zetcode.com/python/fstring/ and https://github.com/frappe/frappe/blame/develop/frappe/utils/commands.py.

I will be investing replacing Python 2 with Python 3…

frappe@ubuntu:~/frappe-bench$ bench update --patch
remote: Enumerating objects: 833, done.
remote: Counting objects: 100% (833/833), done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 1194 (delta 792), reused 790 (delta 771), pack-reused 361
Receiving objects: 100% (1194/1194), 379.33 KiB | 0 bytes/s, done.
Resolving deltas: 100% (931/931), completed with 277 local objects.
From https://github.com/frappe/frappe
 * [new branch]      barredterra-patch-1 -> upstream/barredterra-patch-1
   dc28773..04c9f58  develop    -> upstream/develop
 * [new branch]      michellealva-patch-1 -> upstream/michellealva-patch-1
 * [new branch]      rebrand-ui -> upstream/rebrand-ui
   7b0afa1..7c90130  v10.x.x    -> upstream/v10.x.x
   6d6ce27..92cda7b  version-11-hotfix -> upstream/version-11-hotfix
   987b75f..5afc4bc  version-12-hotfix -> upstream/version-12-hotfix
   22b59ee..90b5b6b  version-13-beta-pre-release -> upstream/version-13-beta-pre-release
Backing up sites...
Patching sites...
Migrating site1.local
Updating DocTypes for frappe        : [========================================]
Updating DocTypes for erpnext       : [========================================]
Updating customizations for Address
Generating Website Theme Files...
Compiling Python Files...
Compiling ../apps/frappe/frappe/integrations/frappe_providers/frappecloud.py ...
  File "../apps/frappe/frappe/integrations/frappe_providers/frappecloud.py", line 199
    print("Uploading files ({}/3)".format(x+1), end="\r")
                                                   ^
SyntaxError: invalid syntax

$ sudo supervisorctl restart frappe-bench-workers: frappe-bench-web:
frappe-bench-workers:frappe-bench-frappe-schedule: stopped
frappe-bench-workers:frappe-bench-frappe-long-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-default-worker-0: stopped
frappe-bench-workers:frappe-bench-frappe-short-worker-0: stopped
frappe-bench-web:frappe-bench-node-socketio: stopped
frappe-bench-web:frappe-bench-frappe-web: stopped
frappe-bench-workers:frappe-bench-frappe-schedule: started
frappe-bench-workers:frappe-bench-frappe-default-worker-0: started
frappe-bench-workers:frappe-bench-frappe-long-worker-0: started
frappe-bench-workers:frappe-bench-frappe-short-worker-0: started
frappe-bench-web:frappe-bench-frappe-web: started
frappe-bench-web:frappe-bench-node-socketio: started
________________________________________________________________________________
Bench: Deployment tool for Frappe and Frappe Applications (https://frappe.io/bench).
Open source depends on your contributions, so please contribute bug reports, patches, fixes or cash and be a part of the com
frappe@ubuntu:~/frappe-bench$

Confirming which version of Python is installed:

frappe@ubuntu:~/frappe-bench$ python -V
Python 2.7.12
frappe@ubuntu:~/frappe-bench$