Repository: aws/aws-sdk-pandas

Issue:
awswrangler import error on python:3.7 dockers
on python:3.7-slim, python:3.7 and python:3.8 import awswrangler suddenly starts failing.

pip3 install --no-cache-dir --trusted-host pypi.python.org awswrangler

Behavior:

import awswrangler as wr

Error:

from awswrangler.pandas import Pandas  # noqa
File "/usr/local/lib/python3.7/site-packages/awswrangler/pandas.py", line 45, in
class Pandas:
File "/usr/local/lib/python3.7/site-packages/awswrangler/pandas.py", line 273, in Pandas
def _read_csv_once_remote(send_pipe: mp.connection.Connection, session_primitives: "SessionPrimitives",
AttributeError: module 'multiprocessing' has no attribute 'connection'

this works fine with image python:3.6

also posted at: https://github.com/docker-library/python/issues/461


Discussion:

I have the same problem using version 0.2.6, I changed my dockerfile to the current version and the error persists when importing the library.

Resolving patch:
diff --git a/awswrangler/pandas.py b/awswrangler/pandas.py
--- a/awswrangler/pandas.py
+++ b/awswrangler/pandas.py
@@ -3,6 +3,7 @@
 import copy
 import csv
 import multiprocessing as mp
+from multiprocessing.connection import Connection as MultiprocessingConnection
 from ast import literal_eval
 from datetime import date, datetime
 from decimal import Decimal
@@ -270,7 +271,7 @@ def _read_csv_once(session_primitives: "SessionPrimitives", bucket_name: str, ke
         return dataframe
 
     @staticmethod
-    def _read_csv_once_remote(send_pipe: mp.connection.Connection, session_primitives: "SessionPrimitives",
+    def _read_csv_once_remote(send_pipe: MultiprocessingConnection, session_primitives: "SessionPrimitives",
                               bucket_name: str, key_path: str, **pd_additional_kwargs):
         df: pd.DataFrame = Pandas._read_csv_once(session_primitives=session_primitives,
                                                  bucket_name=bucket_name,
@@ -884,7 +885,7 @@ def _cast_pandas(dataframe: pd.DataFrame, cast_columns: Dict[str, str]) -> pd.Da
         return dataframe
 
     @staticmethod
-    def _data_to_s3_dataset_writer_remote(send_pipe,
+    def _data_to_s3_dataset_writer_remote(send_pipe: MultiprocessingConnection,
                                           dataframe: pd.DataFrame,
                                           path: str,
                                           partition_cols,
@@ -1295,7 +1296,7 @@ def read_parquet(self,
         return df
 
     @staticmethod
-    def _read_parquet_paths_remote(send_pipe: mp.connection.Connection,
+    def _read_parquet_paths_remote(send_pipe: MultiprocessingConnection,
                                    session_primitives: "SessionPrimitives",
                                    path: Union[str, List[str]],
                                    columns: Optional[List[str]] = None,
@@ -1781,7 +1782,7 @@ def _read_fwf(session_primitives: "SessionPrimitives", bucket_name: str, key_pat
         return dataframe
 
     @staticmethod
-    def _read_fwf_remote(send_pipe: mp.connection.Connection, session_primitives: "SessionPrimitives", bucket_name: str,
+    def _read_fwf_remote(send_pipe: MultiprocessingConnection, session_primitives: "SessionPrimitives", bucket_name: str,
                          key_path: str, **pd_additional_kwargs):
         df: pd.DataFrame = Pandas._read_fwf(session_primitives=session_primitives,
                                             bucket_name=bucket_name,


Test patch: