caffe调试常见问题汇总

(1)^M文件格式问题

bash:./configure /bin/sh^M: bad interpreter: No such file or directory

configure文件是dos格式的,怎么转换成unix格式的呢?
这就要用到vim的强大功能

vim configure

:set ff=unix

:wq
:set ff ? // 查询文件格式

(2)import caffe失败 No module named caffe

在Ubuntu环境下,打开python解释程序,输入import caffe时:出现以下错误

>>>import caffe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named caffe

解决方法:

sudo vim ~/.bashrc 
export PYTHONPATH=~/caffe/python:$PYTHONPATH
source ~/.bashrc

(3)Non-ASCII character ‘\xe6’ in file
SyntaxError: Non-ASCII character ‘\xe6’ in file deploy.py on line 4, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

发现是因为Python在默认状态下不支持源文件中的编码所致。
解决方案有如下三种:

a、在文件头部添加如下注释码:

coding= 例如,可添加# coding=utf-8

b、在文件头部添加如下两行注释码:

#!/usr/bin/python

# -*- coding: <encoding name> -*- 例如,可添加# -*- coding: utf-8 -*-

c、在文件头部添加如下两行注释码:

 #!/usr/bin/python

# vim: set fileencoding=<encoding name> : 例如,可添加# vim: set fileencoding=utf-8 :

猜你喜欢

转载自blog.csdn.net/u014470361/article/details/99487974