pythonpython-3.xhttplibhttplib2

Httplib2 invalid syntax error with [python3.6]


I build app with python3 long time ago. And these days unfortunately I've broken my pc and something happened to my ubuntu server and no longer use so I reconfigured it and cloned my python app from my github repo and deployed by same step before except some dependency's updating. Then I got error message. I know this is a compatibility issue about python 2 and 3. But how can I fix this?

[Thu Mar 07 16:07:12.139598 2019] [wsgi:error] [pid 10828:tid 139884947846912] [remote 99.230.56.77:63637]   File "/var/www/ItemCatalogApp/venv/lib/python3.6/site-packages/httplib2/__init__.py", line 462
[Thu Mar 07 16:07:12.139604 2019] [wsgi:error] [pid 10828:tid 139884947846912] [remote 99.230.56.77:63637]     print("%s:" % h, end=" ", file=self._fp)
[Thu Mar 07 16:07:12.139608 2019] [wsgi:error] [pid 10828:tid 139884947846912] [remote 99.230.56.77:63637]                         ^
[Thu Mar 07 16:07:12.139612 2019] [wsgi:error] [pid 10828:tid 139884947846912] [remote 99.230.56.77:63637] SyntaxError: invalid syntax

Solution

  • I suspect you are running this code in Python 2, not Python 3.

    end= and file= are not valid in Python 2 unless you have from __future__ import print_function at the top of your program.