ImportError cannot import name BytesIO when import caffe on ubuntu

后端 未结 2 952
终归单人心
终归单人心 2021-02-15 18:39

I am trying to make caffe running on my machine equipped with Ubuntu 12.04LTS. After finishing all the steps on the Installation page, I trained the LeNet model successfully an

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-15 19:23

    You appear to have a package or module named io in your Python path that is masking the standard library package. It is imported instead but doesn't have a BytesIO object to import.

    Try running:

    python -c 'import io; print io.__file__'
    

    in the same location you are running the tutorial and rename or move the file named by that import, presuming it is not the standard library version (ending in lib/python2.7/io.pyc).

    It could be you set your Python path to the wrong directory. You should include path/to/caffe/python, not path/to/caffe/python/caffe, nor should you try and run python with the latter as your current working directory. In both cases caffe/python/caffe/io.py instead of the standard library version.

    The installation instructions are not at fault here; they clearly tell you to use:

    export PYTHONPATH=/path/to/caffe/python:$PYTHONPATH
    

    Note the lack of /caffe at the end of that path.

提交回复
热议问题