Google app engine ImportError:没有名为_ctypes的模块在Windows上运行针对Google App Engine的Python Flask教程

Google app engine ImportError:没有名为_ctypes的模块在Windows上运行针对Google App Engine的Python Flask教程,google-app-engine,Google App Engine,我只是想在他们的教程页面上运行简单的hello world应用程序。我过去经常使用谷歌应用程序引擎,但现在我似乎一点也不能用了。我在win 10 x64上。下载了最新的google cloud sdk和python版本2.7.13 > ERROR 2017-01-07 15:25:21,219 wsgi.py:263] Traceback (most recent > call last): File "C:\Program Files (x86)\Google\Cloud

我只是想在他们的教程页面上运行简单的hello world应用程序。我过去经常使用谷歌应用程序引擎,但现在我似乎一点也不能用了。我在win 10 x64上。下载了最新的google cloud sdk和python版本2.7.13

> ERROR    2017-01-07 15:25:21,219 wsgi.py:263] Traceback (most recent
> call last):   File "C:\Program Files (x86)\Google\Cloud
> SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py",
> line 240, in Handle
>     handler = _config_handle.add_wsgi_middleware(self._LoadHandler())   File "C:\Program Files (x86)\Google\Cloud
> SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py",
> line 299, in _LoadHandler
>     handler, path, err = LoadObject(self._handler)   File "C:\Program Files (x86)\Google\Cloud
> SDK\google-cloud-sdk\platform\google_appengine\google\appengine\runtime\wsgi.py",
> line 85, in LoadObject
>     obj = __import__(path[0])   File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\main.py",
> line 18, in <module>
>     from flask import Flask   File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\flask\__init__.py",
> line 21, in <module>
>     from .app import Flask, Request, Response   File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\flask\app.py",
> line 27, in <module>
>     from . import json, cli   File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\flask\cli.py",
> line 17, in <module>
>     import click   File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\__init__.py",
> line 18, in <module> INFO     2017-01-07 10:25:21,229 module.py:806]
> default: "GET / HTTP/1.1" 500 -
>     from .core import Context, BaseCommand, Command, MultiCommand, Group, \   File
> "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\core.py", line 8, in <module>
>     from .types import convert_type, IntRange, BOOL   File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\types.py",
> line 4, in <module>
>     from ._compat import open_stream, text_type, filename_to_ui, \   File
> "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\_compat.py",
> line 536, in <module>
>     from ._winconsole import _get_windows_console_stream   File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\_winconsole.py",
> line 16, in <module>
>     import ctypes   File "C:\Python27\lib\ctypes\__init__.py", line 7, in <module>
>     from _ctypes import Union, Structure, Array   File "C:\Program Files (x86)\Google\Cloud
> SDK\google-cloud-sdk\platform\google_appengine\google\appengine\tools\devappserver2\python\sandbox.py",
> line 964, in load_module
>     raise ImportError('No module named %s' % fullname) 
ImportError: No module named _ctypes
>错误2017-01-07 15:25:21219 wsgi.py:263]回溯(最近
>最后调用):文件“C:\ProgramFiles(x86)\Google\Cloud
>SDK\google cloud SDK\platform\google\u appengine\google\appengine\runtime\wsgi.py“,
>第240行,在手柄中
>handler=\u config\u handle.add\u wsgi\u中间件(self.\u LoadHandler())文件“C:\Program Files(x86)\Google\Cloud
>SDK\google cloud SDK\platform\google\u appengine\google\appengine\runtime\wsgi.py“,
>第299行,in\u LoadHandler
>处理程序,路径,err=LoadObject(self.\u处理程序)文件“C:\Program Files(x86)\Google\Cloud
>SDK\google cloud SDK\platform\google\u appengine\google\appengine\runtime\wsgi.py“,
>第85行,在LoadObject中
>obj=\uuuuu导入(路径[0])文件“C:\....\python docs samples\appengine\standard\flask\hello\u world\main.py”,
>第18行,在
>从flask导入flask文件“C:\..\python docs samples\appengine\standard\flask\hello\u world\lib\flask\\uuuu init\uuuuuuuuuuuuuuuuuuuy”,
>第21行,在
>从.app import Flask、请求、响应文件“C:\....\python docs samples\appengine\standard\Flask\hello\u world\lib\Flask\app.py”,
>第27行,在
>从。导入json,cli文件“C:\..\python docs samples\appengine\standard\flask\hello\u world\lib\flask\cli.py”,
>第17行,在
>导入单击文件“C:\..\python docs samples\appengine\standard\flask\hello\u world\lib\click\\uu init\uuuuuuuuuuuuy.py”,
>信息2017-01-07 10:25:21229模块中的第18行。py:806]
>默认值:“GET/HTTP/1.1”500-
>从.core导入上下文、BaseCommand、Command、MultiCommand、组\文件
>“C:\....\python docs samples\appengine\standard\flask\hello\u world\lib\click\core.py”,中的第8行
>从.types导入convert\u type、IntRange、BOOL文件“C:\....\python docs samples\appengine\standard\flask\hello\u world\lib\click\types.py”,
>第4行,在
>from.\u compat导入打开的\u流、文本类型、文件名\u到\u ui\File
>“C:\..\python docs samples\appengine\standard\flask\hello\u world\lib\click\\u compat.py”,
>第536行,输入
>从.\u winconsole导入\u获取\u windows\u控制台\u流文件“C:\..\python docs samples\appengine\standard\flask\hello\u world\lib\click\\u winconsole.py”,
>第16行,在
>导入ctypes文件“C:\Python27\lib\ctypes\\uuuu init\uuuu.py”,第7行,在
>从\u ctypes导入联合、结构、数组文件“C:\Program Files(x86)\Google\Cloud
>SDK\google cloud SDK\platform\google\u appengine\google\appengine\tools\devappserver2\python\sandbox.py“,
>第964行,加载模块中
>引发导入错误('没有名为%s“%fullname”的模块)
ImportError:没有名为_ctypes的模块
谷歌的示例Flask“Hello World”应用程序需要
Flask 0.11.1

这个库不是谷歌提供的,所以开发者需要通过
pip

此示例显示如何将Flask与Google App Engine Standard一起使用

在运行或部署此应用程序之前,请安装依赖项 使用pip:

pip安装-t lib-r requirements.txt

Flask的
setup.py
pip
安装库,版本高于或等于2.0版

    install_requires=[
        'Werkzeug>=0.7',
        'Jinja2>=2.4',
        'itsdangerous>=0.21',
        'click>=2.0',
],
2015年11月,单击
以改进windows控制台中对unicode的支持。此更改添加了Appengine阻塞的
ctypes
库的导入,因为Appengine沙箱不允许导入
ctypes

解决方法是用早期版本(5.1)覆盖已安装的
单击


pip安装--target lib--upgrade click==5.1

对于我来说,这里提到的解决方法是有效的

  • 转到[sdk\U home]\google\appengine\tools\devappserver2\python\sandbox.py
  • 查找_WHITE_LIST_C_MODULES=[xxx]的定义 在列表中添加以下两行:
    “_winreg”, "类型",
  • 请重试您的应用程序
该问题于2017年7月7日被标记为固定

我正在尝试运行此命令:我正在使用命令dev_appserver.py app.yaml。这是标准烧瓶样品。