ImportError: cannot import name caffe2_pb2 #2099
Comments
try running: |
I found the error.If you run the installations steps when you have an empty PYTHON PATH it will generate a corrupted one because of double ':' |
@filipetrocadoferreira I run into the same problem. Could you tell me how you fixed it? |
@chenlh14 how did you install Caffe2? There should be a caffe2 directory under your site-packages, something like /usr/local/lib/python2.7/site-packages/caffe2 . There should also be a libcaffe2.so located depending on how you installed, in this example it would be at /usr/local/lib/libcaffe2.so . The path to the lib folder containing libcaffe2.so should be in LD_LIBRARY_PATH |
@pjh5 I have not a caffe2 directory under my /python2.7/site-packages, but I have it under /usr/local/lib/python2.7/dist-packages/ and the files in this folder are correctly installed from the installation date and time. echo $LD_LIBRARY_PATH, I get: echo $PYTHONPATH, I get I got Thanks for your continuous help! |
OK , It is really because PYTHONPATH has double ':'. |
@pjh5 excuse me ,i also have the problem and i have not a caffe2 directory in /usr/local/lib/python2.7/site-packages/ and i have not libcaffe2 in /usr/local/lib/,so how to fix it |
I have solved it in my ubuntu16.04, my way is : sudo gedit ~/.bashrc add at the end #caffe2 notes: $PYTHONPATH:# yourcaffe2rootdir/caffe2/build yourcaffe2rootdir you can find the build see where is it .such as mine: /home/xsc/caffe2/build |
Everyone, please do not edit PYTHONPATH or LD_LIBRARY_PATH unless you need to. The install instructions said only to edit those if you were having import problems, because they only apply in certain cases. I have removed all of these commands from the installation instructions. Please read https://caffe2.ai/docs/faq.html#why-do-i-get-import-errors-in-python-when-i-try-to-use-caffe2 and understand what your PYTHONPATH does before changing it. |
double :
So delete PYTHONPATH and add new PYTHONPATH to .bashrc
Add new pythonpath
Then
|
I don't have a double: , and all the paths are right,but the error is still there ,what can I do ? |
Have you made sure your Python follows all the steps in https://caffe2.ai/docs/faq.html#why-do-i-get-import-errors-in-python-when-i-try-to-use-caffe2 ? |
I am new to caffe2,and I build it from docker image, and run it in a docker container, could it be possible to lack packages? |
Hi @zhangwewenwen , I had the same issue as you but I built caffe2 from source. I fixed it in the following way: |
Hi, I just built caffe2 from source successfully in an ubuntu 16.04 docker image following these instructions. When I attempted to test my installation using the suggested command I get an import error on
The location of the
The problem seems to be that
It seems like Other notes:
Summary
|
@manuelli , echo $PYTHONPATH, I get |
@manuelli what you described was indeed a bug which has since been fixed. @sdalxn you probably shouldn't have PYTHONPATH set to anything. Setting it to your build folder will cause python to search in build/*.py files and also in copies of those files in your python site-packages, which may diverge over time if you are editting locally. /usr/local/lib should also not be on your LD_LIBRARY_PATH, unless you have a separate reason for having it there and understand your use case. |
@pjh5 Hi, can you please elaborate on this bug that has been fixed? I just pulled from the latest repo and I still have this issue. It could be for a different issue, but could you please point to the fix? |
@akanazawa the fix was something along the lines of https://github.com/pytorch/pytorch/blob/master/setup.py#L1255 , basically setuptools wasn't including the Caffe2 python source files in the installation directory for the binary builds in certain cases. If you're still getting the error then you have a different problem. |
@pjh5 Thank you for the update! I think this could've fixed it. I ended up going around this issue with docker. |
If this is a build issue, please fill out the template below.
System information
CMake summary output
#Error
The text was updated successfully, but these errors were encountered: