→ Back to Home
Serverless

Using Python libraries with EMR Serverless

Amazon EMR Serverless offers a flexible and scalable environment for running big data workloads, and a key aspect of its utility for data scientists and engineers is the ability to seamlessly integrate Python libraries into PySpark jobs. This AWS documentation provides a detailed walkthrough of the various approaches to achieve this, catering to different complexity levels and use cases. The first method discussed involves utilizing native Python features. This is suitable for scenarios where users need to include individual Python files (.py), zipped Python packages (.zip), or Egg files (.egg) directly with their Spark executors. The documentation provides clear instructions on how to configure `spark.submit.pyFiles` to upload these dependencies, making it straightforward for basic library inclusion. For more complex projects requiring multiple Python libraries or specific versions, the guide recommends building isolated Python virtual environments. This approach ensures that all necessary dependencies are packaged together, preventing conflicts and maintaining a consistent execution environment. The article details the steps for creating such virtual environments, including installing desired packages like `scipy` and `matplotlib`, and then archiving them for deployment to an Amazon S3 location. A crucial note is the importance of building these virtual environments in an environment similar to Amazon Linux 2, matching the Python version used by EMR Serverless, to ensure compatibility. Furthermore, for users leveraging Amazon EMR releases 6.12.0 and higher, the documentation highlights a streamlined method for incorporating popular data science libraries such as `pandas`, `NumPy`, and `PyArrow`. These newer releases allow for direct configuration of PySpark jobs to use these libraries without requiring extensive manual setup, significantly simplifying the development workflow for common data science tasks. The article also touches upon considerations for using different Python versions and optimizing for Graviton (ARM64) architecture, emphasizing the need for compatible third-party packages.
#python#emr serverless#pyspark#aws#data processing#libraries
Read original source