2017-01-07 23 views
4

チュートリアルページで単純なhello worldアプリケーションを実行しようとしています。私は以前はGoogle App Engineを頻繁に使用していましたが、今ではそれをやり遂げることはできません。私は10 x64で勝っています。ダウンロードした最新のGoogleクラウドSDK、およびPythonのバージョン2.7.13ImportError:_ctypesという名前のモジュールがありません。Windows上のGoogle App EngineのPython Flaskチュートリアル

> 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 
+0

実行中のチュートリアルのバージョンはどれですか?これは作成しようとしている環境と一致していますか?そして、あなたはどんな命令を出していますか? – snakecharmerb

+0

私はこれを実行しようとしています:https://github.com/GoogleCloudPlatform/python-docs-samples/tree/master/appengine/standard/flask/hello_world私はコマンドdev_appserver.py app.yamlを使用しています。標準のFlaskサンプルです。 – Bill

答えて

5

Googleのサンプルフラスコの "Hello World" アプリケーションは、Flask 0.11.1が必要です。

開発者が後でよりリリースまたはバージョン2.0に等しいで、clickライブラリをインストールする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

を経由してフラスコのsetup.pyinstructspipそれをインストールするために必要とされるように、このライブラリは、Googleがvendoredされていません。

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

2015年11月にa change was committedclickには、WindowsコンソールでのUnicodeのサポートを改善します。この変更により、Appengineサンドボックスでは​​のインポートが許可されないため、Appengineが窒息している​​ライブラリのインポートが追加されました。

これを回避するには、以前のバージョン(5.1 looks like the most recent candidate)と一緒にインストールclickを上書きすることです。私にとって

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

+0

それは、ありがとう!素晴らしい答え。 – Bill

2

Google's issue tracker

  • 後藤[SDK_HOME働いていたここに記載の回避策] \ google \ appengine \ tools \ devappserver2 \ python \ sandbox.py
  • _WHITE_LIST_C_MODULES = [xxx ] リストに次の2行を追加してください:
    '_winreg'、 '_ctypes'、
  • アプリをもう一度お試しください。

この問題は、2011年7月7日に修正されました。

関連する問題