gpt4 book ai didi

google-app-engine - 导入错误 : No module named _ctypes running Python Flask tutorial for Google App Engine on Windows

转载 作者:太空宇宙 更新时间:2023-11-03 15:27:25 25 4
gpt4 key购买 nike

我只是想在他们的教程页面上运行简单的 hello world 应用程序。我以前经常使用 Google App Engine,但现在我似乎根本无法使用它。我正在赢得 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

最佳答案

Google 的示例 Flask“Hello World”应用程序需要 Flask 0.11.1

此库不是由 Google 提供的,因此开发者需要通过 pip

安装它

This sample shows how to use Flask with Google App Engine Standard.

Before running or deploying this application, install the dependencies using pip:

pip install -t lib -r requirements.txt

Flask 的 setup.py instructs pip 安装 click库,版本晚于或等于 2.0 版。

    install_requires=[
'Werkzeug>=0.7',
'Jinja2>=2.4',
'itsdangerous>=0.21',
'click>=2.0',
],

2015 年 11 月 a change was committed 单击 以改进 Windows 控制台中对 unicode 的支持。此更改添加了 Appengine 阻塞的 ctypes 库的导入,因为 Appengine 沙箱不允许导入 ctypes

解决方法是用较早版本 (5.1 looks like the most recent candidate) 覆盖已安装的 click:

pip install --target lib --upgrade click==5.1

关于google-app-engine - 导入错误 : No module named _ctypes running Python Flask tutorial for Google App Engine on Windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41525223/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com