BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
33.95k stars 18.72k forks source link

python 3 #4692

Open HoloSound opened 7 years ago

HoloSound commented 7 years ago

Regarding http://stackoverflow.com/questions/34295136 caffe works with python 2.7 (not with other versions)

Regarding: http://caffe.berkeleyvision.org/installation.html For Python Caffe: Python 2.7 or Python 3.3+

But there are scripts which do not work in python 3 like:

scripts/download/download_model_binary.py due:

AttributeError: module 'urllib' has no attribute 'urlretrieve'

To run with python 3 it should be changed to:

$ diff download_model_binary.py /opt/caffe/scripts/
5a6
> import urllib
9,17d9
< # import urllib
< # https://stackoverflow.com/questions/17960942
<
< if sys.version_info[0] >= 3:
<     from urllib.request import urlretrieve
< else:
<     # not python 3 - today ... till python 4 exists
<     from urllib import urlretrieve
<
80c72,73
<     urlretrieve( frontmatter['caffemodel_url'], model_filename, reporthook )

---
>     urllib.urlretrieve(
>         frontmatter['caffemodel_url'], model_filename, reporthook)
$
MiguelSimao commented 7 years ago

I had the same problem, the proposed solution worked for me.