Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/285.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 无法导入模块appengine.ext_Python_Google App Engine - Fatal编程技术网

Python 无法导入模块appengine.ext

Python 无法导入模块appengine.ext,python,google-app-engine,Python,Google App Engine,我正在玩ndb,但在用python导入appengine模块时,我被卡住了。这只发生在我的单元测试中。单元测试位于项目根目录下的test.py中 Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more informa

我正在玩ndb,但在用python导入appengine模块时,我被卡住了。这只发生在我的单元测试中。单元测试位于项目根目录下的test.py中

Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from google.appengine.ext import ndb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named appengine.ext
我在Google_appengine中有一个名为Google的目录,其结构如下

.Gooogle
+-- __init__.py
+-- appengine
|   +-- __init__.py
|   +-- ext
    |   +-- ndb
    |   +-- __init__.py

请帮忙

在其外部使用appengine软件包的最简单方法是使用dev_appserver进行设置:

import sys
sys.path.insert(0, '/path/to/google_appengine')
import dev_appserver
dev_appserver.fix_sys_path()

# and then e.g.
from google.appengine.ext import ndb

文件夹
google
的名称是否准确?您的问题似乎显示为
.google

\uuuu init\uuuuuuuuuuuuuuuuuuuuupy
由解释器在扫描PYTHONPATH时使用(PYTHONPATH可以设置为PATH之类的环境变量,或者在代码中使用与其他用户在其答案中包含的模式类似的模式进行修改),尝试查找包含
\uuuuuuuu init\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu。具有自己的
\uuuu init\uuuu.py
的子文件夹也被视为子模块,等等

如果PYTHONPATH包含包含
google
的文件夹,其中包含
\uuuu init\uuuuu.py
和类似
appengine
的文件夹,那么它应该可以在代码中导入。您是否可以尝试运行以下命令并发布输出?这将显示PYTHONPATH中的目录

import sys
print sys.path

我试过你的建议,但还是有同样的错误。“导入错误:没有名为appengine.ext的模块”
import sys
print sys.path