Google App Engine POST 500缺失模块sklearn.pipeline

时间:2017-10-19 18:35:24

标签: python python-2.7 google-app-engine

在UI上运行:它接受一个字符串,将其带到后端(使用Flask,名为main.py),执行一些ML魔法,并将JSON返回到前端。

在本地运行用户界面工作正常,但是当将其部署到Google的App Engine时,我获得状态500.查看日志,我看到我有moduleError: No module named sklearn.pipeline事情是,我不是&# 39; t使用它,这也不是我的requirements.txt这里的日志查看器中的追溯对象:

Traceback (most recent call last):
  File "/env/local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "/env/local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/env/local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/env/local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "/env/local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/vmagent/app/main.py", line 61, in run_pipeline
    text_clf = pickle.load(handle)
ImportError: No module named sklearn.pipeline


{
    insertId: "1mjwzxmecegyg"
    labels: {
        appengine.googleapis.com / instance_name: "aef-default-20171019t101524-k2kk"
        compute.googleapis.com / resource_id: "7187158353674854010"
        compute.googleapis.com / resource_name: "31d3314567f8"
        compute.googleapis.com / zone: "us-central1-b"
    }
    logName: "projects/maximal-ascent-183217/logs/appengine.googleapis.com%2Fstderr"
    receiveTimestamp: "2017-10-19T17:37:19.968312342Z"
    resource: {
        labels: {
            module_id: "default"
            project_id: "maximal-ascent-183217"
            version_id: "20171019t101524"
        }
        type: "gae_app"
    }
    textPayload: "Traceback (most recent call last):
    File "/env/local/lib/python2.7/site-packages/flask/app.py",
    line 1982,
    in wsgi_app
    response = self.full_dispatch_request()
    File "/env/local/lib/python2.7/site-packages/flask/app.py",
    line 1614,
    in full_dispatch_request
    rv = self.handle_user_exception(e)
    File "/env/local/lib/python2.7/site-packages/flask/app.py",
    line 1517,
    in handle_user_exception
    reraise(exc_type, exc_value, tb)
    File "/env/local/lib/python2.7/site-packages/flask/app.py",
    line 1612,
    in full_dispatch_request
    rv = self.dispatch_request()
    File "/env/local/lib/python2.7/site-packages/flask/app.py",
    line 1598,
    in dispatch_request
    return self.view_functions[rule.endpoint]( ** req.view_args)
    File "/home/vmagent/app/main.py",
    line 61,
    in run_pipeline
    text_clf = pickle.load(handle)
    ImportError: No module named sklearn.pipeline "  
    timestamp: "2017-10-19T17:37:18Z"
}

对于此时该做什么感到困惑:我应该安装模块并在main.py中使用它吗?

1 个答案:

答案 0 :(得分:0)

我会发布我发现的解决方案:

虽然我的main.py不需要scipy或sklearn,但我需要在requirements.txt中为其中一个pickle文件提供这些模块。在部署到App Engine时,必须确保您的requirements.txt是一致的。