caffe2 icon indicating copy to clipboard operation
caffe2 copied to clipboard

ImportError: No module named caffe2.python

Open wfilleman opened this issue 9 years ago • 4 comments

Hi folks,

I was able to build Caffe2 on Windows 10 with Anaconda2 without issues. When I tried to run the RNN sample from: https://caffe2.ai/docs/RNNs-and-LSTM-networks.html

I see this error:

python char_rnn.py --train_data shakespeare.txt
Traceback (most recent call last):
  File "char_rnn.py", line 8, in <module>
    from caffe2.python import core, workspace, cnn, utils
ImportError: No module named caffe2.python

I've copied the caffe2_pybind11_state.pyd file into the Anaconda2\DLLs folder.

What did I miss?

Thanks for any suggestions. Wes

wfilleman avatar Apr 21 '17 16:04 wfilleman

Seems like a pythonpath issue - you should set your pythonpath to where caffe2 is built/installed. This link would be helpful:

http://stackoverflow.com/questions/3701646/how-to-add-to-the-pythonpath-in-windows-7

Yangqing avatar Apr 21 '17 16:04 Yangqing

I have this issue too. Here's what I did:

  1. Copy caffe2_pybind11_state.pyd to 'C:\Python27amd64\DLLs'
  2. In python interpreter:
>>> import sys
>>> sys.path
  1. Verify 'C:\Python27amd64\DLLs' is in that path
  2. Interpreter: >>> import caffe2 Result:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named caffe2

rodmanlau avatar Jun 16 '17 21:06 rodmanlau

Ah, okay, Yangqing is right. The following interpreter line resolves the issue: >>> sys.path.append('C:\\Users\\<username>\\Source\\Repos\\Python\\caffe2\\build') import caffe2

Works.

rodmanlau avatar Jun 16 '17 21:06 rodmanlau

I have this issue.the folder 'C:\Users\\Source\Repos\' is empty. what do you think its mean?

HRubaye avatar Feb 18 '18 21:02 HRubaye