Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-1293

Module initialization error when using pyarrow with AWS Lambda

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • 0.5.0
    • None
    • Python
    • None
    • AWS Lambda

    Description

      When using pyarrow in AWS Lambda function like this:

      import pyarrow as pa
      import pyarrow.parquet as pq
      import pandas as pd
      
      def lambda_handler(event, context):
          df = pd.DataFrame([data]) #data is dictionary
          table = pa.Table.from_pandas(df)
          pq.write_table(table, 'tmp/test.parquet', compression='snappy')
          table = pq.read_table('tmp/test.parquet')
          table.to_pandas()
          print(table)
          return "Success"
      

      Module initialization error occurs:

      module initialization error: [Errno 2] No such file or directory: '/var/task/__pycache__/_cffi__x762f05ffx6bf5342b.c'
      

      Deployment package was prepared by running following commands:

      virtualenv nameofenv
      source nameofenv/bin/active
      pip install pyarrow
      sudo apt-get install libsnappy-dev
      pip install python-snappy
      pip install pandas
      

      files from site-packages directory are than zipped together with lambda function.

      Attachments

        Activity

          wesm Wes McKinney added a comment -

          This does not seem obviously related to pyarrow. What happens if you exclude pyarrow from the deployment package?

          wesm Wes McKinney added a comment - This does not seem obviously related to pyarrow. What happens if you exclude pyarrow from the deployment package?

          wesmckinn you are right, it seems like it is because of python-snappy that depends on cffi

          tmilicic Tanja Miličić added a comment - wesmckinn you are right, it seems like it is because of python-snappy that depends on cffi
          mdurant Martin Durant added a comment -

          This very likely comes from snappy for the specific case of Lambda: https://github.com/andrix/python-snappy/issues/52

          mdurant Martin Durant added a comment - This very likely comes from snappy for the specific case of Lambda: https://github.com/andrix/python-snappy/issues/52
          rokm Rok Mihevc added a comment -

          This issue has been migrated to issue #15443 on GitHub. Please see the migration documentation for further details.

          rokm Rok Mihevc added a comment - This issue has been migrated to issue #15443 on GitHub. Please see the migration documentation for further details.

          People

            wesm Wes McKinney
            tmilicic Tanja Miličić
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: