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 frappe/frappe/utils/commands.py at develop · frappe/frappe · GitHub.

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$
1 Like

Just got this error, not only that python version need to be version 3 but it need to be version 3.6+, since f-string got introduce in python3.6.

To check you python version.

bench console
import sys
sys.version

I am also having same issue
Can somebody help with the syntax what to enter?

I am on debian 9.5
$ python --version => Python 2.7.13
$ ls /usr/bin/python* => many python version show up, including python3.5

I have already tried:
$ bench migrate-env python3

When I do:
bench console
import sys
sys.version
=> result is 3.5.3

However, when I bench update, the same error as the original poster shows up
Would appreciate your help
Thank you

Fwiw I finally gave up trying to upgrade Python in the erpnext.com virtual machine download. Python 2 is too much a part of Ubuntu 16.04 LTS. Instead I created a new vm using Ubuntu 20.04 LTS (based on Easy install setup guide for erpnext installation on Ubuntu 20.04 LTS. With some modification of course) and imported a backup from the original server.

Hi

I am using ubuntu 16.04, as someone already pointed that it is the problem of python, even I have faced same issue, you can use the following steps to change your python environment.

  1. Since the latest version of python in ubuntu 16.04 is 3.5 and I had to install 3.6, I used 3rd party repository to install it as shown here How to Install Latest Python 3.11 in Ubuntu

  2. Once installation is done please check the default python in your system and if require change it to python 3.6 using options, the command is "sudo update-alternatives --config python3 "

output:

Blockquote
There are 2 choices for the alternative python3 (providing /usr/bin/python3).

Selection Path Priority Status

  • 0 /usr/bin/python3.6 2 auto mode
    1 /usr/bin/python3.5 1 manual mode
    2 /usr/bin/python3.6 2 manual mode

Press to keep the current choice[*], or type selection number:

in my case its already 3.6

  1. Now switch to frappe user and run bench migrate-env python3 and you are done.

Regards

Version-12 is meant to be compatible with PY2 and PY3. Although, these errors shouldn’t interfere in your usages. Unless, you use bench --site migrate-to frappe.cloud. However, the compatibility issues are fixed. For v12, this will be fixed in the next minor release.