谷歌用c不用python_ImportError:没有名为_ctypes的模块在Windows上运行Google App Engine的Python Flask教程...

I'm just trying to run the simple hello world app on their tutorials page. I used to use Google App Engine frequently, but now I can't seem to get it going at all. I'm on win 10 x64. Downloaded latest google cloud sdk, and python version 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

> from flask import Flask File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\flask\__init__.py",

> line 21, in

> from .app import Flask, Request, Response File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\flask\app.py",

> line 27, in

> from . import json, cli File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\flask\cli.py",

> line 17, in

> import click File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\__init__.py",

> line 18, in 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

> from .types import convert_type, IntRange, BOOL File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\types.py",

> line 4, in

> 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

> from ._winconsole import _get_windows_console_stream File "C:\....\python-docs-samples\appengine\standard\flask\hello_world\lib\click\_winconsole.py",

> line 16, in

> import ctypes File "C:\Python27\lib\ctypes\__init__.py", line 7, in

> 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's sample Flask "Hello World" application requires Flask 0.11.1.

This library is not vendored by Google, so developers are required to install it via 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's setup.py instructs pip to install the click library, at a release later than or equal to version 2.0.

install_requires=[

'Werkzeug>=0.7',

'Jinja2>=2.4',

'itsdangerous>=0.21',

'click>=2.0',

],

In November 2015 a change was committed to click to improve support for unicode in the windows console. This change added the import of the ctypes library which Appengine is choking on, because the Appengine sandbox does not allow importing ctypes.

The workaround for this is to overwrite the installed click with an earlier version (5.1 looks like the most recent candidate):

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值