Reputation: 377
I have followed all the steps on https://cloud.google.com/appengine/docs/go/#creating_a_simple_http_handler on how to get started with Go, but I am stuck on an issue while trying to run the helloworld app.
I get the following error:
C:\Users\kirill\Desktop\go_appengine>goapp serve myapp
Traceback (most recent call last):
File "C:\Users\kirill\Desktop\go_appengine\\dev_appserver.py", line 83, in <module>
_run_file(__file__, globals())
File "C:\Users\kirill\Desktop\go_appengine\\dev_appserver.py", line 79, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
NameError: name 'execfile' is not defined
error while running dev_appserver.py: exit status 1
Upvotes: 1
Views: 8183
Reputation: 87
I've just stumbled upon similar issue myself, In Python 3 Instead of
execfile("./filename")
Use
exec(open("./filename").read())
Upvotes: 1
Reputation: 417672
Go AppEngine SDK requires Python 2.7 (Python 3.x cannot be used). It looks to me your SDK is using Python 3.X or you don't have Python at all (in your PATH
).
First make sure Python 2.7 is added to your PATH so that will be used by goapp
. You can get it here: Python 2.7.11. For the Go AppEngine SDK a small, portable Python is also enough, you can get it from here: Single-File Stand-alone Python 2.7.9 for Windows. Download pyexe-2.7.9.10.zip and extract it. It's just a 10 MB single file, rename it to python.exe
and add it to your PATH
.
Also going further, it looks to me you are starting your Hello world app from the wrong folder: you are standing in the SDK's folder, and you want to start it specifying that your app is in the myapp
subfolder inside your SDK, which is unlikely.
Navigate to the folder where you app is (app.yaml
must be there). In that folder execute the command
goapp serve
This will start the app being in the current folder. For this to work, the goapp
command (goapp.bat
on windows) must be added to your PATH
.
If you can't or don't want to add your go_appengine
folder to your PATH
, still navigate to the folder containing the app you want to start, but provide the path for goapp, e.g.
C:\Users\kirill\Desktop\go_appengine\goapp serve
Upvotes: 4