gpt4 book ai didi

python - 即使我没有安装 webapp2,import webapp2 也可以在 google-app-engine 上运行

转载 作者:行者123 更新时间:2023-11-28 20:51:31 24 4
gpt4 key购买 nike

当我运行以下 hellow world 程序(使用 GAE Launcher)时,它工作正常:

import webapp2

class MainPage(webapp2.RequestHandler):
def get(self):
self.response.headers['Content-Type'] = 'text/plain'
self.response.out.write('Hello, webapp World!')

app = webapp2.WSGIApplication([('/', MainPage)],
debug=True)

但是,如果我去终端,我无法导入 webapp2:

C:\Users\Robert>python
Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import webapp2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named webapp2
>>>

我的 IDE 也没有为 webapp2 对象提供自动完成功能。

鉴于 GAE 启动器使用与我在终端中使用的相同的 python 版本,我对导入必须如何在 GAE 启动器中工作感到困惑。

最佳答案

这不是错误。 Appengine SDK 从 1.6 版本开始包括 webapp2。

默认情况下,您无法从终端导入 webapp2,因为 google_appengine默认情况下不添加到 PATH。

将以下目录添加到 Python 的 PATH; C:\Program Files\Google\google_appengine\C:\Program Files\Google\google_appengine\lib\您将拥有 SDK 提供的相同环境。

关于python - 即使我没有安装 webapp2,import webapp2 也可以在 google-app-engine 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9509276/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com