Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ubuntu | Python wrapper]: cannot "import caffe" #720

Closed
luzhi opened this issue Jul 18, 2014 · 12 comments
Closed

[Ubuntu | Python wrapper]: cannot "import caffe" #720

luzhi opened this issue Jul 18, 2014 · 12 comments

Comments

@luzhi
Copy link

luzhi commented Jul 18, 2014

I cannot "import caffe" in my python interactive shell. The error message is:

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

I performed "make pycaffe" in /caffe/ folder after "make all" and check all the dependencies. The ubuntu version is 14.04, python 2.7.6 .

In addition, if I tried to "import _caffe.so" the error message is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: libcudart.so.6.0: cannot open shared object file: No such file or directory

Thanks!

@shuokay
Copy link

shuokay commented Jul 18, 2014

pls import caffe in $CAFFE/python or add the path to sys.path

@luzhi
Copy link
Author

luzhi commented Jul 18, 2014

@shuokay Could you please advise me more detailed steps? Thanks!

@luzhi
Copy link
Author

luzhi commented Jul 24, 2014

@shuokay Thank you! The method at http://www.johnny-lin.com/cdat_tips/tips_pylang/path.html works.

@luzhi
Copy link
Author

luzhi commented Jul 24, 2014

Also, in Ubuntu, the python wrapper can be added into the PYTHONPATH in the file ".bashrc" at /home .

export PYTHONPATH=/home/username/caffe/python

@LinZhineng
Copy link

@luzhi Thanks for your answer

@aragon111
Copy link

@luzhi should I type, every timy I open the python console:
export PYTHONPATH=/home/username/caffe/python
from home ?

(sorry I'm a bit confused)

@antiDigest
Copy link

@attiliotnt

luzhi said add this line in your ".bashrc" file which is located at "/home".

That way, terminal will run this line every time you open it ! So, no, you don't have to run it every time.

@sayadyaghoobi
Copy link

i got the same error! anyone has solved this please give us the point. i compiled and set path correctly but still it give me no caffe module found

@antiDigest
Copy link

@sayadyaghoobi
I am hoping you are compiling caffe twice (i.e. once in the main repository and the other time in the recursively imported repository) and then posting the problems ?

Also, the PYTHONPATH exported would be better as:
export PYTHONPATH=/complete/path/to/caffe/python:$PYTHONPATH

in either your ~/.bashrc or ~/.bash_profile.

(The $PYTHONPATH also appends everything else in the new PYTHONPATH)

@MingmingWarm
Copy link

caffe_root = '../../../caffe-master/' (This is the path of caffe-master)
import sys
sys.path.insert(0, caffe_root + 'python')
import caffe

you should add above lines in the script.

@DerOzean
Copy link

Okay, I ran in the same Problem.
I tried to import chainer and use caffe
I found a solution here: https://teratail.com/questions/82964
So do this in top of your code:
import chainer
import chainer.links
from chainer.links import caffe
The original code was :
import chainer
import chainer.functions as F
from chainer.functions import caffe
Please also import functions as F so the code will work as it was intended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants