Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module found

I install caffe and it worked fine. In cmd, I can import it use python, but when I use jupyter notebook, I can't import it.

enter image description here

enter image description here

How can I solve it?

like image 801
KAIYUAN ZHNAG Avatar asked Apr 26 '26 11:04

KAIYUAN ZHNAG


1 Answers

It looks like you have put /home/mltitan/Workspace/caffepython in the path instead of /home/mltitan/Workspace/caffe/python which may have been your intention.

Adding the strings together as you have done will not insert the slash in the path. Best practise is to use os.path.join to handle this:

import os
import sys

caffe_root = '/home/mltitan/Workspace/caffe'
sys.path.insert(0, os.path.join(caffe_root, 'python'))
import caffe

Does that help?

like image 190
Simon Bowly Avatar answered Apr 28 '26 01:04

Simon Bowly



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!