goapp serve: 找不到 dev_appserver.py

huangapple go评论140阅读模式
英文:

goapp serve: unable to find dev_appserver.py

问题

使用go 1.2、python 2.7和appengine 1.8.9。

dev_appserver.py在命令提示符中可以运行,并且位于Windows路径中。

goapp.exe也可以在命令提示符中运行,并且位于Windows路径中。

有任何想法为什么goapp.exe serve无法工作?

英文:

using go 1.2 python 2.7 and appengine 1.8.9

dev_appserver.py works in dos box and is located in windows path.

goapp.exe also works in dos box and is located in windows path.

Any idea why goapp.exe serve does not work?

答案1

得分: 4

goapp/serve.go产生了这个错误信息("无法找到dev_appserver.py"),它显示了以下代码:

if p := os.Getenv("APPENGINE_DEV_APPSERVER"); p != "" {
  return p, nil
}
return "", fmt.Errorf("无法找到dev_appserver.py")

因此,请仔细检查在使用goapp时,APPENGINE_DEV_APPSERVER环境变量是否实际设置了。例如,查看这个gotool.bat脚本,它确实设置了该变量(但dsymonds正确地指出,你不应该直接设置它,你应该始终使用goapp):

@echo off
:: 版权所有 2012 Google Inc.
:: 使用此源代码受 Apache 2.0 许可证的约束
:: 许可证可以在 LICENSE 文件中找到。
setlocal
set GOROOT=%~dp0\goroot
set APPENGINE_DEV_APPSERVER=%~dp0\dev_appserver.py
set GOARCH=
set GOBIN=
set GOOS=

:: 如果未设置GOPATH,则设置一个GOPATH。
if not "%GOPATH%"=="" goto havepath
set GOPATH=%~dp0\gopath
:havepath

%GOROOT%\bin\%~n0.exe %*
英文:

The goapp/serve.go which produces this error message ("unable to find dev_appserver.py") shows the following code:

if p := os.Getenv("APPENGINE_DEV_APPSERVER"); p != "" {
  return p, nil
}
return "", fmt.Errorf("unable to find dev_appserver.py")

So double-check if, when using goapp, APPENGINE_DEV_APPSERVER environment variable was actually set.
See for instance this gotool.bat script which does set that variable
(but dsymonds rightly points out that you should not set it directly, you should always use goapp):

@echo off
:: Copyright 2012 Google Inc. All rights reserved.
:: Use of this source code is governed by the Apache 2.0
:: license that can be found in the LICENSE file.
setlocal
set GOROOT=%~dp0\goroot
set APPENGINE_DEV_APPSERVER=%~dp0\dev_appserver.py
set GOARCH=
set GOBIN=
set GOOS=

:: Set a GOPATH if one is not set.
if not "%GOPATH%"=="" goto havepath
set GOPATH=%~dp0\gopath
:havepath

%GOROOT%\bin\%~n0.exe %*

huangapple
  • 本文由 发表于 2014年1月18日 08:42:15
  • 转载请务必保留本文链接:https://go.coder-hub.com/21198584.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定