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

python can't import _caffe module #2757

Closed
rwhchan opened this issue Jul 13, 2015 · 13 comments
Closed

python can't import _caffe module #2757

rwhchan opened this issue Jul 13, 2015 · 13 comments

Comments

@rwhchan
Copy link

rwhchan commented Jul 13, 2015

This is a slightly different problem from #263 so I've opened a new issue since that was closed.

Using cygwin, I tried the following

cmake (flags) ..
make all
make pycaffe

using the cmake procedure and generated _caffe.so, then did an export PYTHONPATH to the right directory (........../caffe/python), but Python (IDLE or IPython) doesn't recognize the file. I get the "no module named _caffe" (not "no module named caffe") error.

Does anyone know how to solve this? Thanks!

@seanbell
Copy link

Is caffe being built properly? There should be a _caffe.so file (caffe/python/caffe/_caffe.so) corresponding to the compiled python package.

If you're using cygwin, are you trying to build it inside windows? Windows isn't officially supported, but some people have ported it (e.g. https://github.com/niuzhiheng/caffe).

@rwhchan
Copy link
Author

rwhchan commented Jul 13, 2015

Yes, the _caffe.so file is there, but Python doesn't read it even though I've added the folder to PYTHONPATH.

It's inside Windows, but the cygwin packages are being used.

@seanbell
Copy link

What is your PYTHONPATH? A very common mistake is to add caffe/python/caffe, when caffe/python should be added instead.

@rwhchan
Copy link
Author

rwhchan commented Jul 14, 2015

It's caffe/python.

@praveen-palanisamy
Copy link

Are you sure _caffe.so is inside your caffe/python/caffe directory?
Just to confirm, make sure:

  1. PYTHONPATH includes your caffe/python directory
  2. caffe/python/caffe contains _caffe.so file.

The python interpreter should then be able to do import caffe successfully (assuming you have installed all other dependencies for the python caffe module).

@chrsp
Copy link

chrsp commented Nov 27, 2015

Any update? I have the same problem here. _caffe.so is inside my /python/caffe folder but when I try to import the error described is returned.

PS: The compilation presented no errors (make all, make test, make runtest and make pycaffe).

image

EDIT: All requirements are ok:

image

My bash_profile file:

image

@DelightRun
Copy link

I have the same error. Are we all use anaconda? Is it only occurs with anaconda?
By the way, Anaconda don't use PYTHONPATH. Maybe this is the reason.
Any ideas?

@xxw345
Copy link

xxw345 commented Apr 24, 2016

export PYTHONPATH={Path2yourCaffe}/caffe/python:$PYTHONPATH

I don't think it has anything to do with Anaconda

@seanbell
Copy link

Closing as this is an installation question; please using the mailing list.

From https://github.com/BVLC/caffe/blob/master/CONTRIBUTING.md:

Please do not post usage, installation, or modeling questions, or other requests for help to Issues.
Use the caffe-users list instead. This helps developers maintain a clear, uncluttered, and efficient view of the state of Caffe.

@drcrook1
Copy link

Rats, I have this same issue, is there a solution?

@walegahaha
Copy link

Are you sure _caffe.so is inside your caffe/python/caffe directory?
Just to confirm, make sure:

1.PYTHONPATH includes your caffe/python directory
2.caffe/python/caffe contains _caffe.so file.

The python interpreter should then be able to do import caffe successfully (assuming you have installed all other dependencies for the python caffe module).

BESIDES
PAY ATTENTION!!!

export PYTHONPATH=/home/walegahaha/caffe/python:$PYTHONPATH
(though my 'caffe' is in /home, we also need to add '/walegahaha'[user name])

@selinachenxi
Copy link

I have the same issue, and using anaconda. Any solutions? I don't have this problem without anaconda before.

@masoodmortazavi
Copy link

This may a binary distribution problem.

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

No branches or pull requests

10 participants