Google AppEngine Python灵活环境中的Catboost

时间:2018-04-24 16:59:03

标签: python google-app-engine-python app-engine-flexible catboost

我尝试设置一个简单的Google AppEngine应用,通过POST请求获取JSON数据并应用Catboost分类器。

我使用的是Python 3.6,并且我在catboost==0.8文件中添加了requirements.txt

但是,部署失败:

ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
[2018-04-24 16:42:04 +0000] [1] [INFO] Starting gunicorn 19.7.1
[2018-04-24 16:42:04 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[2018-04-24 16:42:04 +0000] [1] [INFO] Using worker: sync
[2018-04-24 16:42:04 +0000] [9] [INFO] Booting worker with pid: 9
[2018-04-24 16:42:05 +0000] [9] [ERROR] Exception in worker process
Traceback (most recent call last):
  File "/env/lib/python3.6/site-packages/gunicorn/arbiter.py", line 578, in spawn_worker
    worker.init_process()
  File "/env/lib/python3.6/site-packages/gunicorn/workers/base.py", line 126, in init_process
    self.load_wsgi()
  File "/env/lib/python3.6/site-packages/gunicorn/workers/base.py", line 135, in load_wsgi
    self.wsgi = self.app.wsgi()
  File "/env/lib/python3.6/site-packages/gunicorn/app/base.py", line 67, in wsgi
    self.callable = self.load()
  File "/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
    return self.load_wsgiapp()
  File "/env/lib/python3.6/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/env/lib/python3.6/site-packages/gunicorn/util.py", line 352, in import_app
    __import__(module)
  File "/home/vmagent/app/main.py", line 8, in <module>
    from catboost import CatBoostClassifier, Pool
  File "/env/lib/python3.6/site-packages/catboost/__init__.py", line 1, in <module>
    from .core import Pool, CatBoost, CatBoostClassifier, CatBoostRegressor, CatboostError, cv, train  # noqa
  File "/env/lib/python3.6/site-packages/catboost/core.py", line 50, in <module>
    _catboost = get_catboost_bin_module()
  File "/env/lib/python3.6/site-packages/catboost/core.py", line 46, in get_catboost_bin_module
    import _catboost
  ModuleNotFoundError: No module named '_catboost'

我的基础Dockerfile如下:

FROM gcr.io/google-appengine/python

# Create a virtualenv for dependencies. This isolates these packages from
# system-level packages.
RUN virtualenv /env -p python3

# Setting these environment variables are the same as running
# source /env/bin/activate.
ENV VIRTUAL_ENV /env
ENV PATH /env/bin:$PATH

RUN apt-get update; \
        apt-get install -y \
        build-essential \
        python-dev \
        python-setuptools \
        python-matplotlib \
        libatlas-dev \
        curl \
        ssh \
        libatlas3gf-base && \
        apt-get clean

# Copy the application's requirements.txt and run pip to install all
# dependencies into the virtualenv.
ADD requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt

我怀疑导致sys.modules_catboost没有注册catboost的问题。 在Google AppEngine Flexible Environment上,有没有办法使用使用C库的第三方应用,例如Catboost?

1 个答案:

答案 0 :(得分:0)

AppEngine Flex不支持Python 3.6 + Catboost是没有技术原因的,因为它完全是用户可配置的。 documentation确认App Engine Flex支持Python 3.6。这是因为App Engine Flex允许您将自己的容器运送到Flex,或修改默认容器。您可以查看this link如何修改默认容器