3

次の場所から Google Go HelloWorld チュートリアルの作業を開始します。

https://developers.google.com/appengine/docs/go/gettingstarted/helloworld

MacBook Pro で OS X 10.8.2 を使用しています。

手順に従いましたが、最初のコード ( dev_appserver.py myapp/ ) を実行すると、質問の最後にエラーが表示されます。

これは、Hello World プログラムです。

package hello

import (
    "fmt"
    "net/http"
)

func init() {
    http.HandleFunc("/", handler)
}

func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprint(w, "Hello, world!")
}

これは構成ファイルです。

application: helloworld
version: 1
runtime: go
api_version: go1

ハンドラ:

- url: /.*
  script: _go_app

ここでスタックオーバーフローをグーグルで検索しましたが、解決策が見つかりませんでした。

アイデアや提案があれば教えてください。

Last login: Sun Oct 14 13:05:37 on ttys000
derek-etnyres-macbook-pro-2:~ dereketnyre$ dev_appserver.py myapp/
WARNING  2012-10-14 18:19:54,239 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.
Warning: You are using a Python runtime (2.7) that is more recent than the production runtime environment (2.5). Your application may use features that are not available in the production environment and may not work correctly when deployed to production.
CRITICAL 2012-10-14 18:19:54,686 appcfg.py:562] The api_version specified in app.yaml (go1) is not supported by this release of the SDK.  The supported api_versions are ['1'].

==========

アップデート

api_version を 1 ( api_version: 1) に変更すると、役に立ちました。それでもエラー メッセージが表示されますが、サーバーは起動します。

それは今言う:

derek-etnyres-macbook-pro-2:~ dereketnyre$ dev_appserver.py myapp/
WARNING  2012-10-14 21:03:14,910 rdbms_mysqldb.py:74] The rdbms API is not available because the MySQLdb library could not be loaded.
Warning: You are using a Python runtime (2.7) that is more recent than the production runtime environment (2.5). Your application may use features that are not available in the production environment and may not work correctly when deployed to production.
INFO     2012-10-14 21:03:15,324 appcfg.py:585] Checking for updates to the SDK.
INFO     2012-10-14 21:03:15,551 appcfg.py:603] The SDK is up to date.
WARNING  2012-10-14 21:03:15,551 datastore_file_stub.py:518] Could not read datastore data from /var/folders/s0/095xdtkd3cgbjp73tpxx309r0000gn/T/dev_appserver.datastore
WARNING  2012-10-14 21:03:15,552 simple_search_stub.py:949] Could not read search indexes from /var/folders/s0/095xdtkd3cgbjp73tpxx309r0000gn/T/dev_appserver.searchindexes
WARNING  2012-10-14 21:03:15,562 dev_appserver.py:3621] Could not initialize images API; you are likely missing the Python "PIL" module. ImportError: No module named _imaging
INFO     2012-10-14 21:03:15,570 dev_appserver_multiprocess.py:655] Running application dev~helloworld on port 8080: http://localhost:8080
INFO     2012-10-14 21:03:15,570 dev_appserver_multiprocess.py:657] Admin console is available at: http://localhost:8080/_ah/admin

Safari を使用して localhost:8080 にアクセスすると、hello ワードが表示されず、画面に python スクリプトの例外がいっぱい表示されます。

一番下には次のように書かれています。

<type 'exceptions.Exception'>: no goroot found at /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/goroot 
      args = ('no goroot found at /Applications/GoogleAppEngine...bundle/Contents/Resources/google_appengine/goroot',) 
      message = 'no goroot found at /Applications/GoogleAppEngine...bundle/Contents/Resources/google_appengine/goroot'

パスが正しく設定されていないように見えますか?

Python エラーの全文は次のとおりです。

pe 'exceptions.AttributeError'> Python 2.7.2: /usr/bin/python
Sun Oct 14 21:29:05 2012
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.

 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py in _HandleRequest(self=<google.appengine.tools.dev_appserver.DevAppServerRequestHandler instance>)
   2952         outfile = cStringIO.StringIO()
   2953         try:
=> 2954           self._Dispatch(dispatcher, self.rfile, outfile, env_dict)
   2955         finally:
   2956           self.module_manager.UpdateModuleFileModificationTimes()
self = <google.appengine.tools.dev_appserver.DevAppServerRequestHandler instance>, self._Dispatch = <bound method DevAppServerRequestHandler._Dispat...v_appserver.DevAppServerRequestHandler instance>>, dispatcher = <google.appengine.tools.dev_appserver.MatcherDispatcher object>, self.rfile = <socket._fileobject object>, outfile = <cStringIO.StringO object>, env_dict = {'APPENGINE_RUNTIME': 'go', 'APPLICATION_ID': 'dev~helloworld', 'CURRENT_VERSION_ID': '1.1', 'DEFAULT_VERSION_HOSTNAME': 'localhost:8080', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_ID_HASH': 'C1DFD96E', 'REQUEST_METHOD': 'GET', 'SDK_VERSION': '1.7.2', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', ...}
 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py in _Dispatch(self=<google.appengine.tools.dev_appserver.DevAppServerRequestHandler instance>, dispatcher=<google.appengine.tools.dev_appserver.MatcherDispatcher object>, socket_infile=<socket._fileobject object>, outfile=<cStringIO.StringO object>, env_dict={'APPENGINE_RUNTIME': 'go', 'APPLICATION_ID': 'dev~helloworld', 'CURRENT_VERSION_ID': '1.1', 'DEFAULT_VERSION_HOSTNAME': 'localhost:8080', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_ID_HASH': 'C1DFD96E', 'REQUEST_METHOD': 'GET', 'SDK_VERSION': '1.7.2', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', ...})
   2822           dispatcher.Dispatch(app_server_request,
   2823                               outfile,
=> 2824                               base_env_dict=env_dict)
   2825         finally:
   2826           request_file.close()
base_env_dict undefined, env_dict = {'APPENGINE_RUNTIME': 'go', 'APPLICATION_ID': 'dev~helloworld', 'CURRENT_VERSION_ID': '1.1', 'DEFAULT_VERSION_HOSTNAME': 'localhost:8080', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_ID_HASH': 'C1DFD96E', 'REQUEST_METHOD': 'GET', 'SDK_VERSION': '1.7.2', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', ...}
 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py in Dispatch(self=<google.appengine.tools.dev_appserver.MatcherDispatcher object>, request=<AppServerRequest relative_url: / path: _go_app ...p', mode 'rb' at 0x106afb030> force_admin: False>, outfile=<cStringIO.StringO object>, base_env_dict={'APPENGINE_RUNTIME': 'go', 'APPLICATION_ID': 'dev~helloworld', 'CURRENT_VERSION_ID': '1.1', 'DEFAULT_VERSION_HOSTNAME': 'localhost:8080', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_ID_HASH': 'C1DFD96E', 'REQUEST_METHOD': 'GET', 'SDK_VERSION': '1.7.2', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', ...})
    705         forward_request = dispatcher.Dispatch(request,
    706                                               outfile,
=>  707                                               base_env_dict=base_env_dict)
    708 
    709         while forward_request:
base_env_dict = {'APPENGINE_RUNTIME': 'go', 'APPLICATION_ID': 'dev~helloworld', 'CURRENT_VERSION_ID': '1.1', 'DEFAULT_VERSION_HOSTNAME': 'localhost:8080', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_ID_HASH': 'C1DFD96E', 'REQUEST_METHOD': 'GET', 'SDK_VERSION': '1.7.2', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', ...}
 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py in Dispatch(self=<google.appengine.tools.dev_appserver.CGIDispatcher object>, request=<AppServerRequest relative_url: / path: _go_app ...p', mode 'rb' at 0x106afb030> force_admin: False>, outfile=<cStringIO.StringO object>, base_env_dict={'APPENGINE_RUNTIME': 'go', 'APPLICATION_ID': 'dev~helloworld', 'CURRENT_VERSION_ID': '1.1', 'DEFAULT_VERSION_HOSTNAME': 'localhost:8080', 'REMOTE_ADDR': '127.0.0.1', 'REQUEST_ID_HASH': 'C1DFD96E', 'REQUEST_METHOD': 'GET', 'SDK_VERSION': '1.7.2', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '8080', ...})
   1770                      memory_file,
   1771                      outfile,
=> 1772                      self._module_dict)
   1773     finally:
   1774       logging.root.level = before_level
self = <google.appengine.tools.dev_appserver.CGIDispatcher object>, self._module_dict = {'codecs': <module 'codecs' from '/System/Library/Framework...framework/Versions/2.7/lib/python2.7/codecs.pyc'>, 'email': <module 'email' from '/System/Library/Frameworks...k/Versions/2.7/lib/python2.7/email/__init__.pyc'>, 'email.Charset': <email.LazyImporter object>, 'email.Encoders': <email.LazyImporter object>, 'email.Errors': <email.LazyImporter object>, 'email.FeedParser': <email.LazyImporter object>, 'email.Generator': <email.LazyImporter object>, 'email.Header': <email.LazyImporter object>, 'email.Iterators': <email.LazyImporter object>, 'email.MIMEAudio': <email.LazyImporter object>, ...}
 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/dev_appserver.py in ExecuteCGI(config=<AppInfoExternal version=1 source_lang...e=None runtime=go api_config=None >, root_path='/Users/dereketnyre/myapp', handler_path='_go_app', cgi_path='/Users/dereketnyre/myapp/_go_app', env={'APPENGINE_RUNTIME': 'go', 'APPLICATION_ID': 'dev~helloworld', 'AUTH_DOMAIN': 'gmail.com', 'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'CURRENT_VERSION_ID': '1.1', 'DEFAULT_VERSION_HOSTNAME': 'localhost:8080', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE': 'en-us', ...}, infile=<cStringIO.StringO object>, outfile=<cStringIO.StringO object>, module_dict={'codecs': <module 'codecs' from '/System/Library/Framework...framework/Versions/2.7/lib/python2.7/codecs.pyc'>, 'email': <module 'email' from '/System/Library/Frameworks...k/Versions/2.7/lib/python2.7/email/__init__.pyc'>, 'email.Charset': <email.LazyImporter object>, 'email.Encoders': <email.LazyImporter object>, 'email.Errors': <email.LazyImporter object>, 'email.FeedParser': <email.LazyImporter object>, 'email.Generator': <email.LazyImporter object>, 'email.Header': <email.LazyImporter object>, 'email.Iterators': <email.LazyImporter object>, 'email.MIMEAudio': <email.LazyImporter object>, ...}, exec_script=<function ExecuteOrImportScript>, exec_py27_handler=<function ExecutePy27Handler>)
   1588     from google.appengine.ext.go import execute_go_cgi
   1589     return execute_go_cgi(root_path, config, handler_path, cgi_path,
=> 1590         env, infile, outfile)
   1591 
   1592 
env = {'APPENGINE_RUNTIME': 'go', 'APPLICATION_ID': 'dev~helloworld', 'AUTH_DOMAIN': 'gmail.com', 'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'CURRENT_VERSION_ID': '1.1', 'DEFAULT_VERSION_HOSTNAME': 'localhost:8080', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE': 'en-us', ...}, infile = <cStringIO.StringO object>, outfile = <cStringIO.StringO object>
 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/go/__init__.py in execute_go_cgi(root_path='/Users/dereketnyre/myapp', config=<AppInfoExternal version=1 source_lang...e=None runtime=go api_config=None >, handler_path='_go_app', cgi_path='/Users/dereketnyre/myapp/_go_app', env={'APPENGINE_RUNTIME': 'go', 'APPLICATION_ID': 'dev~helloworld', 'AUTH_DOMAIN': 'gmail.com', 'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'CURRENT_VERSION_ID': '1.1', 'DEFAULT_VERSION_HOSTNAME': 'localhost:8080', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE': 'en-us', ...}, infile=<cStringIO.StringO object>, outfile=<cStringIO.StringO object>)
    519     RAPI_HANDLER = handler.ApiCallHandler()
    520     GO_APP = GoApp(root_path)
=>  521   GO_APP.make_and_run(env)
    522 
    523 
global GO_APP = None, GO_APP.make_and_run undefined, env = {'APPENGINE_RUNTIME': 'go', 'APPLICATION_ID': 'dev~helloworld', 'AUTH_DOMAIN': 'gmail.com', 'CONTENT_LENGTH': '', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'CURRENT_VERSION_ID': '1.1', 'DEFAULT_VERSION_HOSTNAME': 'localhost:8080', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HTTP_ACCEPT': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'HTTP_ACCEPT_LANGUAGE': 'en-us', ...}
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'make_and_run' 
      args = ("'NoneType' object has no attribute 'make_and_run'",) 
      message = "'NoneType' object has no attribute 'make_and_run'"
4

2 に答える 2

3

カイルからの答えを拡張して、これを機能させるために私がしたことは次のとおりです。

  1. SDK をダウンロード
  2. /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine に解凍します
  3. (開いている場合は) GAE Launcher を閉じて、再実行します。
  4. アプリを起動し、ブラウザで開きます
于 2012-10-15T03:54:19.433 に答える
2

Go は、インストールした Python バージョンとは別の SDK を使用します。ここからダウンロードしてください:

Go 用 Google App Engine SDK

dev_appserver.pyサーバーを起動するときに必ずスクリプトを実行してください。

于 2012-10-15T03:21:12.020 に答える