gpt4 book ai didi

python导入错误 "No module named appengine.ext"

转载 作者:IT老高 更新时间:2023-10-28 22:21:11 27 4
gpt4 key购买 nike

运行这段代码后,我发现导入错误:-

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

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

application = webapp.WSGIApplication([('/', MainPage)],debug=True)

def main():
run_wsgi_app(application)

if __name__ == "__main__":
main()

如何使用 google.apengine.ext

最佳答案

import sys
sys.path.insert(1, '/Users/<username>/google-cloud-sdk/platform/google_appengine')
sys.path.insert(1, '/Users/<username>/google-cloud-sdk/platform/google_appengine/lib/yaml/lib')
sys.path.insert(1, 'lib')

if 'google' in sys.modules:
del sys.modules['google']

这解决了我的问题

关于python导入错误 "No module named appengine.ext",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15783783/

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