diff --git a/dockers/docker-sonic-mgmt/Dockerfile.j2 b/dockers/docker-sonic-mgmt/Dockerfile.j2
index ca1a42e84798..5f880dda7d9a 100644
--- a/dockers/docker-sonic-mgmt/Dockerfile.j2
+++ b/dockers/docker-sonic-mgmt/Dockerfile.j2
@@ -34,6 +34,7 @@ RUN apt-get update && apt-get install -y build-essential \
                                          vim
 
 RUN pip install cffi==1.10.0 \
+                contextlib2==0.6.0.post1 \
                 cryptography==3.3.2 \
                 "future>=0.16.0" \
                 gitpython \
diff --git a/src/sonic-config-engine/setup.py b/src/sonic-config-engine/setup.py
index 9e98ff607bd4..236d39e7117c 100644
--- a/src/sonic-config-engine/setup.py
+++ b/src/sonic-config-engine/setup.py
@@ -33,7 +33,8 @@
         'Jinja2<3.0.0',
         'pyangbind==0.6.0',
         'zipp==1.2.0',  # importlib-resources needs zipp and seems to have a bug where it will try to install too new of a version for Python 2
-        'importlib-resources==3.3.1'  # importlib-resources v4.0.0 was released 2020-12-23 and drops support for Python 2
+        'importlib-resources==3.3.1',  # importlib-resources v4.0.0 was released 2020-12-23 and drops support for Python 2
+        'contextlib2==0.6.0.post1'
     ]
 
 # Common modules for python2 and python3