我已经安装了protobuf
套餐,但我无法导入。
> pip uninstall protobuf
... uninstalls
> pip install protobuf
... installs. confirm that it's installed:
pip install protobuf
Requirement already satisfied (use --upgrade to upgrade): protobuf in ./.venv/lib/python3.5/site-packages
Requirement already satisfied (use --upgrade to upgrade): setuptools in ./.venv/lib/python3.5/site-packages (from protobuf)
Requirement already satisfied (use --upgrade to upgrade): six>=1.9 in ./.venv/lib/python3.5/site-packages (from protobuf)
回到ipython
:
In [1]: from google.protobuf import descriptor as _descriptor
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-3baca6afb060> in <module>()
----> 1 from google.protobuf import descriptor as _descriptor
ImportError: No module named google.protobuf
In [2]:
我真的很难过。
> python --version
> Python 3.5.1
> which pip
/Users/skyler/work/TemplateProcessor/.venv/bin/pip
> pip --version
pip 8.1.2 from /Users/skyler/work/TemplateProcessor/.venv/lib/python3.5/site-packages (python 3.5)
答案 0 :(得分:-1)
我遇到了同样的问题,并在this issue中找到了解决方法:
1.添加新文件tensorflow / google / init.py:
try: import pkg_resources pkg_resources.declare_namespace(__name__) except ImportError: import pkgutil __path__ = pkgutil.extend_path(__path__, __name__) Add namespace_packages to tensorflow/google/protobuf/python/setup.py: setup( name='protobuf', namespace_packages=['google'], ... )
- 重新编译/ pip安装。祝你好运!
醇>