英文:
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 %*
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论