KoBoCAT SyntaxError: invalid syntax

Hello, I am facing unexpected runtime issues since the last few days, not being able to run my localhost instance in developer mode anymore (I haven’t tried on staging mode yet).

After calling
python3 run.py

The backend and frontend containers run as usually, but the system gets stuck in the last step:
Waiting for environment to be ready. It can take a few minutes.

When I try with
python3 run.py --logs

The output shows that kobocat is running into issues, showing constantly the message from below.

Note: a week ago everything was running as expected, and I haven’t touched the kobocat repository.

I hope you could help me find the root of this issue.


kobocat_1         | You should consider upgrading via the 'pip install --upgrade pip' command.
kobocat_1         | Running `kobocat` container with `runserver_plus` debugging application server.
kobocat_1         | Collecting werkzeug==0.16.0
kobocat_1         |   Using cached https://files.pythonhosted.org/packages/ce/42/3aeda98f96e85fd26180534d36570e4d18108d62ae36f87694b476b83d6f/Werkzeug-0.16.0-py2.py3-none-any.whl
kobocat_1         | Collecting ipython
kobocat_1         |   Using cached https://files.pythonhosted.org/packages/ce/2c/2849a2b37024a01a847c87d81825c0489eb22ffc6416cac009bf281ea838/ipython-5.10.0-py2-none-any.whl
kobocat_1         | Collecting prompt-toolkit<2.0.0,>=1.0.4 (from ipython)
kobocat_1         |   Using cached https://files.pythonhosted.org/packages/9d/d2/2f099b5cd62dab819ce7a9f1431c09a9032fbfbb6474f442722e88935376/prompt_toolkit-1.0.18-py2-none-any.whl
kobocat_1         | Requirement already satisfied: setuptools>=18.5 in /usr/local/lib/python2.7/dist-packages (from ipython) (41.0.1)
kobocat_1         | Collecting backports.shutil-get-terminal-size; python_version == "2.7" (from ipython)
kobocat_1         |   Using cached https://files.pythonhosted.org/packages/7d/cd/1750d6c35fe86d35f8562091737907f234b78fdffab42b29c72b1dd861f4/backports.shutil_get_terminal_size-1.0.0-py2.py3-none-any.whl
kobocat_1         | Collecting decorator (from ipython)
kobocat_1         |   Using cached https://files.pythonhosted.org/packages/71/bd/042e63027bea950da4e6f5545eb59b973868da854ab30a18128d3b884104/decorator-5.0.2.tar.gz
kobocat_1         |     Complete output from command python setup.py egg_info:
kobocat_1         |     Traceback (most recent call last):
kobocat_1         |       File "<string>", line 1, in <module>
kobocat_1         |       File "/tmp/pip-install-tKKDLH/decorator/setup.py", line 4, in <module>
kobocat_1         |         exec(open('src/decorator.py').read(), dic)  # extract the __version__
kobocat_1         |       File "<string>", line 162
kobocat_1         |         print('Error in generated code:', file=sys.stderr)
kobocat_1         |                                               ^
kobocat_1         |     SyntaxError: invalid syntax
kobocat_1         |
kobocat_1         |     ----------------------------------------
kobocat_1         | Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-tKKDLH/decorator/```

Hello again,

In the end I had to upgrade pip on KoBoCAT to the latest version in order to have the container running with no errors.


  1. Change this line: kobocat/Dockerfile at 78133d519f7b7674636c871e3ba5670cd64a7227 · kobotoolbox/kobocat · GitHub
    RUN pip install --upgrade 'pip>=20'

  2. Rebuild the images (rebuilding just KoBoCAT should do as well):
    python3 run.py --build

Hope this helps anyone having the same issue.



@dj_1, thank you for sharing the solution with the entire community! :clap:

1 Like

I think its because in Python 3, print statement has been replaced with a print() function, with keyword arguments to replace most of the special syntax of the old print statement. But if you write this in a program and someone using Python 2.x tries to run it, they will get an error. To avoid this, it is a good practice to import print function:

from __future__ import print_function

Now your code works on both python2 and python3

1 Like

Welcome to the community, @warnerarc! And thank you for making our community rich with contents related to KoBoToolbox. Expecting the same in the upcoming days too.

Hi @warnerarc, we have purposely removed support for Python 2.x as it no longer receives support from the maintainers :+1:

1 Like