dongtidai6519 2012-10-14 18:32
浏览 66
已采纳

Google Go Hello World教程错误了

Starting to work through the Google Go HelloWorld tutorial from:

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

Using OS X 10.8.2 on MacBook Pro.

Followed the steps, but when I run the first code ( dev_appserver.py myapp/ ), I get errors listed at end of question.

This is the hello world program:

package hello

import (
    "fmt"
    "net/http"
)

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

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

and this is the configuration file:

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

handlers:

- url: /.*
  script: _go_app

Have googled and searched here on stackoverflow, but not found solution.

Let me know if you have any ideas/suggestions.

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'].

==========

Update

Changed the api_version to be 1 ( api_version: 1) and it did help. Still gives error message but the server starts.

It now says:

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

When I go to localhost:8080 using Safari - does not display hello word - gives a screen full of python script exceptions.

At the very bottom it says:

<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'

Looks like the path is not set correctly?

The full text of the python errors is:

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'"
  • 写回答

2条回答 默认 最新

  • douwang4374 2012-10-15 03:54
    关注

    Extending the answer from Kyle, this is what I did to get it working:

    1. Download the SDK
    2. Extract it to /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine
    3. Close (if its open) GAE Launcher and re-run it
    4. Start your app and open it in the browser
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗