Python import caffe: invalid syntax

968 views
Skip to first unread message

PenguinEngineer

unread,
Aug 4, 2016, 1:13:40 PM8/4/16
to Caffe Users

Hi,
I have a problem when I try to import the caffe module for python.

I have done


make all
make pycaffe
make distribute


I have the _caffe.so module under caffe/distribute/python/caffe.

I set my PYTHONPATH: it looks like this:

/home/luca/caffe/distribute/python:

But when I run import caffe in the python shell (under /home/luca/caffe/python) I have this output:


>>> import caffe
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/luca/caffe/python/caffe/__init__.py", line 1, in <module>
    from .pycaffe import Net, SGDSolver, NesterovSolver, AdaGradSolver, RMSPropSolver, AdaDeltaSolver, AdamSolver
  File "/home/luca/caffe/python/caffe/pycaffe.py", line 15, in <module>
    import caffe.io
  File "/home/luca/caffe/python/caffe/io.py", line 2, in <module>
    import skimage.io
  File "/usr/lib/python3.5/site-packages/skimage/io/__init__.py", line 15, in <module>
    reset_plugins()
  File "/usr/lib/python3.5/site-packages/skimage/io/manage_plugins.py", line 93, in reset_plugins
    _load_preferred_plugins()
  File "/usr/lib/python3.5/site-packages/skimage/io/manage_plugins.py", line 73, in _load_preferred_plugins
    _set_plugin(p_type, preferred_plugins['all'])
  File "/usr/lib/python3.5/site-packages/skimage/io/manage_plugins.py", line 85, in _set_plugin
    use_plugin(plugin, kind=plugin_type)
  File "/usr/lib/python3.5/site-packages/skimage/io/manage_plugins.py", line 255, in use_plugin
    _load(name)
  File "/usr/lib/python3.5/site-packages/skimage/io/manage_plugins.py", line 299, in _load
    fromlist=[modname])
  File "/usr/lib/python3.5/site-packages/skimage/io/_plugins/matplotlib_plugin.py", line 3, in <module>
    import matplotlib.pyplot as plt
  File "/usr/lib/python3.5/site-packages/matplotlib/pyplot.py", line 36, in <module>
    from matplotlib.figure import Figure, figaspect
  File "/usr/lib/python3.5/site-packages/matplotlib/figure.py", line 40, in <module>
    from matplotlib.axes import Axes, SubplotBase, subplot_class_factory
  File "/usr/lib/python3.5/site-packages/matplotlib/axes/__init__.py", line 4, in <module>
    from ._subplots import *
  File "/usr/lib/python3.5/site-packages/matplotlib/axes/_subplots.py", line 10, in <module>
    from matplotlib.axes._axes import Axes
  File "/usr/lib/python3.5/site-packages/matplotlib/axes/_axes.py", line 23, in <module>
    import matplotlib.dates as _  # <-registers a date unit converter
  File "/usr/lib/python3.5/site-packages/matplotlib/dates.py", line 126, in <module>
    from dateutil.rrule import (rrule, MO, TU, WE, TH, FR, SA, SU, YEARLY,
  File "/usr/lib/python3.5/site-packages/dateutil/rrule.py", line 55
    raise ValueError, "Can't create weekday with n == 0"
                    ^
**SyntaxError: invalid syntax**

>>> 


Anyone could help me?

Regards

Wang Yifu

unread,
Aug 8, 2016, 8:51:29 PM8/8/16
to Caffe Users
I encountered the same problem and just solved it. You should make the version of python-dateutil >= 2.0 in python/requirement.txt

在 2016年8月4日星期四 UTC-7上午10:13:40,PenguinEngineer写道:

Hala Neji

unread,
Feb 22, 2017, 8:33:08 AM2/22/17
to Caffe Users
I encountered the same problem
Message has been deleted
Message has been deleted

sungwo...@gmail.com

unread,
Sep 4, 2017, 1:51:09 AM9/4/17
to Caffe Users
Thanks from Wang Yifu, I solved this problem with
pip3 install python-dateutil --upgrade
(or use python2, using 'pip')

sungwo...@gmail.com

unread,
Sep 4, 2017, 1:54:12 AM9/4/17
to Caffe Users
(double hyphen), font of code highlighter is may not good :(
Reply all
Reply to author
Forward
0 new messages