简体   繁体   English

Pycharm问题-ImportError:没有名为appengine.datastore.datastore_query的模块

[英]Pycharm issue - ImportError: No module named appengine.datastore.datastore_query

I have been trying to use the excellent project located at http://docs.gae-init.appspot.com/ , in order to learn python, GAE and perhaps start my own hobby project. 我一直在尝试使用位于http://docs.gae-init.appspot.com/上的出色项目,以学习python,GAE并可能开始我自己的业余爱好项目。 My IDE of choice is Pycharm 3.4 Professional Edition. 我选择的IDE是Pycharm 3.4 Professional Edition。 Operating system is OSX Mavericks. 操作系统是OSX Mavericks。

I have been trying to follow the tutorial, therefore I have git cloned the project at a local directory and subsequently opened in into Pycharm. 我一直在尝试按照教程进行操作,因此我将git克隆到本地目录中,然后将其打开到Pycharm中。 I believe I have managed to resolve the majority of requirements (PyCharm helps a lot). 我相信我已经设法解决了大多数要求(PyCharm可以提供很多帮助)。

Nevertheless, when trying to Run the project I get the following error: 但是,在尝试运行项目时,出现以下错误:

  File "/Users/nilminus/Developer/phonebook/main/main.py", line 9, in <module>
    import util
  File "/Users/nilminus/Developer/phonebook/main/util.py", line 10, in <module>
    from google.appengine.datastore.datastore_query import Cursor
ImportError: No module named appengine.datastore.datastore_query

I have configured GAE directory as /usr/local/google_appengine which is correct. 我已将GAE目录配置为/ usr / local / google_appengine,这是正确的。 Pycharm does not complain about not finding this module before actually executing it. Pycharm不会抱怨在实际执行该模块之前找不到该模块。 There is a warning that module google is not listed in requirements.txt, but it does not makes sense to me that this could be the issue. 有一个警告,说明Google模块未在requirements.txt中列出,但对我来说这可能不是问题。

I have included PYTHONPATH in .profile and ~/.bash_profile: PYTHONPATH=/usr/local/google_appengine/:/usr/local/google_appengine/lib/:/usr/local/google_appengine/lib/yaml/ 我已经在.profile和〜/ .bash_profile中包含了PYTHONPATH:PYTHONPATH = / usr / local / google_appengine /:/ usr / local / google_appengine / lib /:/ usr / local / google_appengine / lib / yaml /

The funny thing is that if I upload this exact project in GAE, it works perfectly. 有趣的是,如果我在GAE中上传这个确切的项目,它会完美运行。 Also, if I run this project with ./run.py -s (as exhibited by its author), it works again. 另外,如果我使用./run.py -s运行该项目(如其作者所示),它将再次运行。 Even ./dev_appserver.py main/ works. 甚至./dev_appserver.py main /也可以。

This issue has truely dazzled me that last week. 上个星期,这个问题确实使我眼花azz乱。 Any help is highly appreciated. 非常感谢您的帮助。

When creating Google Engine App project, specify App Engine SDK path in App Engine SDK directory field: 创建Google Engine App项目时,请在App Engine SDK目录字段中指定App Engine SDK路径:

App Engine项目设置

Note: PyCharm automatically detects the GAE installation path, and displays it in this field. 注意:PyCharm会自动检测GAE安装路径,并将其显示在此字段中。 However, Auto-detection works for Windows and OS X. For Linux, you have to specify the App Engine SDK yourself. 但是,自动检测适用于Windows和OSX。对于Linux,您必须自己指定App Engine SDK。

Also specify SDK path in Settings 同时在“设置”中指定SDK路径 App Engine路径

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM