Python google cloud function won’t import pandas

I’m having a problem where I’m trying to deploy a google cloud function and have narrowed down the source of the problem to the import of pandas in the function. But the strange thing is that this was working for me a few days ago and then suddenly stopped working and it took quite a bit of time to narrow down and figure out exactly what was going wrong. To summarize, I have a test_fcn that is laid out below and it won’t deploy. However, if I comment out the “import pandas” line then the function deploys correctly. At this point, the function doesn’t do anything: it’s just a test vehicle to demonstrate the problem. I’m confused and would like to know how to get pandas to import properly because I need to use that library for running my real function. And, to repeat myself, the real function was running a few days ago but when I redeployed the “last successful deployment” yesterday it failed. Has anyone seen this problem or a similar problem and know what might be going on?

 

Here is the requirements.txt

functions-framework==3.*
pandas==2.0.3
 

And here is the test function:

import pandas as p

import functions_framework

 

@functions_framework.http

def hello_http(request):

 

    response = run_test_fcn()

    return 'ok', 200

 

def run_test_fcn():

  return 'ok'

 

Here is the log output, starting with the first traceback

ERROR 2024-06-17T17:28:38.213663Z Traceback (most recent call last): File “/layers/google.python.pip/pip/bin/functions-framework”, line 8, in <module> sys.exit(_cli())

DEFAULT 2024-06-17T17:28:38.213686Z ^^^^^^

DEFAULT 2024-06-17T17:28:38.213692Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/click/core.py”, line 1157, in _call_

DEFAULT 2024-06-17T17:28:38.214692Z return self.main(*args, **kwargs)

DEFAULT 2024-06-17T17:28:38.214866Z ^^^^^^^^^^^^^^^^^^^^^^^^^^

DEFAULT 2024-06-17T17:28:38.214874Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/click/core.py”, line 1078, in main

DEFAULT 2024-06-17T17:28:38.215191Z rv = self.invoke(ctx)

DEFAULT 2024-06-17T17:28:38.215296Z ^^^^^^^^^^^^^^^^

DEFAULT 2024-06-17T17:28:38.215312Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/click/core.py”, line 1434, in invoke

DEFAULT 2024-06-17T17:28:38.215689Z return ctx.invoke(self.callback, **ctx.params)

DEFAULT 2024-06-17T17:28:38.215907Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

DEFAULT 2024-06-17T17:28:38.215918Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/click/core.py”, line 783, in invoke

DEFAULT 2024-06-17T17:28:38.216116Z return __callback(*args, **kwargs)

DEFAULT 2024-06-17T17:28:38.216213Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^

DEFAULT 2024-06-17T17:28:38.216219Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/functions_framework/_cli.py”, line 36, in _cli

DEFAULT 2024-06-17T17:28:38.217937Z app = create_app(target, source, signature_type)

DEFAULT 2024-06-17T17:28:38.218094Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

DEFAULT 2024-06-17T17:28:38.218111Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/functions_framework/_init_.py”, line 395, in create_app

DEFAULT 2024-06-17T17:28:38.219695Z raise e from None

DEFAULT 2024-06-17T17:28:38.219716Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/functions_framework/_init_.py”, line 376, in create_app

DEFAULT 2024-06-17T17:28:38.219860Z spec.loader.exec_module(source_module)

DEFAULT 2024-06-17T17:28:38.219897Z File “<frozen importlib._bootstrap_external>”, line 940, in exec_module

DEFAULT 2024-06-17T17:28:38.219904Z File “<frozen importlib._bootstrap>”, line 241, in _call_with_frames_removed

DEFAULT 2024-06-17T17:28:38.219909Z File “/workspace/main.py”, line 1, in <module>

DEFAULT 2024-06-17T17:28:38.219971Z import pandas

DEFAULT 2024-06-17T17:28:38.219993Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/pandas/_init_.py”, line 22, in <module>

DEFAULT 2024-06-17T17:28:38.221548Z from pandas.compat import is_numpy_dev as _is_numpy_dev # pyright: ignore # noqa:F401

DEFAULT 2024-06-17T17:28:38.221728Z ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

DEFAULT 2024-06-17T17:28:38.221734Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/pandas/compat/_init_.py”, line 25, in <module>

DEFAULT 2024-06-17T17:28:38.223044Z from pandas.compat.numpy import (

DEFAULT 2024-06-17T17:28:38.223060Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/pandas/compat/numpy/_init_.py”, line 4, in <module>

DEFAULT 2024-06-17T17:28:38.224803Z from pandas.util.version import Version

DEFAULT 2024-06-17T17:28:38.224814Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/pandas/util/_init_.py”, line 2, in <module>

DEFAULT 2024-06-17T17:28:38.226038Z from pandas.util._decorators import ( # noqa:F401

DEFAULT 2024-06-17T17:28:38.226048Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/pandas/util/_decorators.py”, line 14, in <module>

DEFAULT 2024-06-17T17:28:38.228236Z from pandas._libs.properties import cache_readonly

DEFAULT 2024-06-17T17:28:38.228265Z File “/layers/google.python.pip/pip/lib/python3.11/site-packages/pandas/_libs/_init_.py”, line 13, in <module>

DEFAULT 2024-06-17T17:28:38.228801Z from pandas._libs.interval import Interval

DEFAULT 2024-06-17T17:28:38.228810Z File “pandas/_libs/interval.pyx”, line 1, in init pandas._libs.interval

WARNING 2024-06-17T17:28:38.932291632Z Container called exit(1).

DEFAULT 2024-06-17T17:28:38.932507Z ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

ERROR 2024-06-17T17:28:39.021017Z Default STARTUP TCP probe failed 1 time consecutively for container “worker” on port 8080. The instance was not started.

ERROR 2024-06-17T17:28:39.037091Z [protoPayload.serviceName: run.googleapis.com] [protoPayload.methodName: v1] [protoPayload.resourceName: namespaces/sample-datasets-400819/revisions/test-fcn-00009-dew] Ready condition status changed to False for Revision test-fcn-00009-dew with message: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information. Logs URL: https://console.cloud.google.com/logs/viewer?project=sample-datasets-400819&resource=cloud_run_revision/service_name/test-fcn/revision_name/test-fcn-00009-dew&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22test-fcn%22%0Aresource.labels.revision_name%3D%22test-fcn-00009-dew%22 For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start

ERROR 2024-06-17T17:28:39.134491Z [protoPayload.serviceName: run.googleapis.com] [protoPayload.methodName: v1] [protoPayload.resourceName: namespaces/sample-datasets-400819/services/test-fcn] Ready condition status changed to False for Service test-fcn with message: Revision ‘test-fcn-00009-dew’ is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information. Logs URL: https://console.cloud.google.com/logs/viewer?project=sample-datasets-400819&resource=cloud_run_revision/service_name/test-fcn/revision_name/test-fcn-00009-dew&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22test-fcn%22%0Aresource.labels.revision_name%3D%22test-fcn-00009-dew%22 For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start

ERROR 2024-06-17T17:28:39.314237610Z [protoPayload.serviceName: cloudfunctions.googleapis.com] [protoPayload.methodName: google.cloud.functions.v2.FunctionService.UpdateFunction] [protoPayload.resourceName: projects/sample-datasets-400819/locations/us-central1/functions/test_fcn] [protoPayload.authenticationInfo.principalEmail: [email protected]] Could not create or update Cloud Run service test-fcn, Container Healthcheck failed. Revision ‘test-fcn-00009-dew’ is not ready and cannot serve traffic. The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable. Logs for this revision might contain more information. Logs URL: https://console.cloud.google.com/logs/viewer?project=sample-datasets-400819&resource=cloud_run_revision/service_name/test-fcn/revision_name/test-fcn-00009-dew&advancedFilter=resource.type%3D%22cloud_run_revision%22%0Aresource.labels.service_name%3D%22test-fcn%22%0Aresource.labels.revision_name%3D%22test-fcn-00009-dew%22 For more troubleshooting guidance, see https://cloud.google.com/run/docs/troubleshooting#container-failed-to-start

The first line of the traceback ends abruptly on the first line of code so it is not really telling me that the problem is with pandas which is also confusing. However, I have verified that commenting out the “import pandas” line makes it so that the function deploys correctly and uncommenting it yields the traceback shown above. Help anyone?

I tried all combinations of including code and import statements. The only thing that seems to reliably invoke the error is the inclusing of the “import pandas” line and it doesn’t matter whether it’s “import pandas as pd” or not. The error is the same, as you would expect.

New contributor

Rudy Hofmeister is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật