这类似于这个问题,但没有提出解决方案。
我有 ~/google_appengine/google/appengine 和 /usr/lib64/python2-7/site-packages/google/protobuf。
我无法“导入 google.appengine”,因为另一个 google 文件夹妨碍了我。我该如何解决?
这是一个最小的示例和错误:
$ python
Python 2.7.3 (default, Jun 12 2012, 13:50:02)
[GCC 4.5.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import google.appengine
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named appengine
根据要求,这是我的 sys.path:
['', '/usr/lib64/python2.7/site-packages/nose-1.1.2-py2.7.egg', '/usr/lib64/python2.7/site-packages/mock-0.8.0-py2.7.egg', '/usr/lib64/python2.7/site-packages/coverage-3.5.1-py2.7-linux-x86_64.egg', '/usr/lib64/python2.7/site-packages/rosinstall-0.6.11-py2.7.egg', '/usr/lib64/python2.7/site-packages/vcstools-0.1.12-py2.7.egg', '/home/murph/google_appengine', '/home/murph/google_appengine/google/appengine', '/home/murph/google_appengine/google', '/home/murph/ros/ros/core/roslib/src', '/usr/lib/portage/pym', '/usr/lib64/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/lib64/python2.7/site-packages', '/usr/lib64/python2.7/site-packages/PIL', '/usr/lib64/python2.7/site-packages/gst-0.10', '/usr/lib64/python2.7/site-packages/gtk-2.0', '/usr/lib64/python2.7/site-packages/wx-2.8-gtk2-unicode', '/usr/lib64/portage/pym']
这显示了它正在导入哪个“谷歌”:
$ python
Python 2.7.3 (default, Jun 12 2012, 13:50:02)
[GCC 4.5.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import google
>>> print google.__path__
['/usr/lib64/python2.7/site-packages/google']