当前位置: 动力学知识库 > 问答 > 编程问答 >

python - ImportError: No module named google.protobuf.text_format

问题描述:

I can find the text_format.py file inside the folder /usr/local/lib/python2.7/dist-packages/google/protobuf/.

But in my python program,I have error as ImportError: No module named google.protobuf.text_format.

I set PYTHONPATH and echo $PYTHONPATH gives me

/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages/google/protobuf:

Why this line from google.protobuf.text_format import Merge in my python program can't import google.protobuf.text_format

网友答案:

Just create a blank file in the folder /usr/local/lib/python2.7/dist-packages/google/protobuf/ with name __init__.py

run this command and it will do it:

touch /usr/local/lib/python2.7/dist-packages/google/protobuf/__init__.py

Check if any issues thereafter.

网友答案:

The root cause of the problem is because of having two python2.7 in my system. One is Anacoda and another one is Python2.7 installed. I think, because of mishandling, there are some conflicts. So I uninstall Anacoda and reinstall all required packages manually. Then the problem is solved.

分享给朋友:
您可能感兴趣的文章:
随机阅读: