Search code examples
pythonparsingtensorflowpython-module

Error with backquotes when import parser from dateutil with Python3.5


I used Tensorflow. It was working. After I installed Caffe (with all dependencies) my old TF projects stopped working.

The root cause is:

from dateutil import parser as _date_parser

gives

/usr/bin/python3.5 /data/PycharmProjects/tensorflow/test/test1.py
Traceback (most recent call last):
  File "/data/PycharmProjects/tensorflow/test/test1.py", line 1, in <module>
    from dateutil import parser as _date_parser
  File "/usr/local/lib/python3.5/dist-packages/dateutil/parser.py", line 158
    l.append("%s=%s" % (attr, `value`))
                              ^
SyntaxError: invalid syntax

Process finished with exit code 1

as a result

import tensorflow as tf

doesn't work because of dependencies

Why is it happened? It was working before Caffe installation.


Solution

  • Is it possible that installing your Caffe updated Python? A L-O-O-N-G time ago Python used backticks as a shortcut for calling the repr function on its argument. Replacing the backtick-quoted expression with repr(value) might be all you need.