diff --git a/flatpak/org.gajim.Gajim.yaml b/flatpak/org.gajim.Gajim.yaml
index 307a9c646217d9a8aa2b3bae32700ff112431e67..0b349a7a7c80194a699fecdfce220f869c603f2e 100644
--- a/flatpak/org.gajim.Gajim.yaml
+++ b/flatpak/org.gajim.Gajim.yaml
@@ -49,6 +49,24 @@ cleanup:
   - '*.la'
 
 modules:
+  - name: python3-pyparsing
+    buildsystem: simple
+    build-commands:
+      - pip3 install --prefix=/app pyparsing-2.4.7-py2.py3-none-any.whl
+    sources:
+      - type: file
+        url: https://files.pythonhosted.org/packages/8a/bb/488841f56197b13700afd5658fc279a2025a39e22449b7cf29864669b15d/pyparsing-2.4.7-py2.py3-none-any.whl
+        sha256: ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b
+
+  - name: python3-packaging
+    buildsystem: simple
+    build-commands:
+      - pip3 install --prefix=/app packaging-20.3-py2.py3-none-any.whl
+    sources:
+      - type: file
+        url: https://files.pythonhosted.org/packages/62/0a/34641d2bf5c917c96db0ded85ae4da25b6cd922d6b794648d4e7e07c88e5/packaging-20.3-py2.py3-none-any.whl
+        sha256: 82f77b9bee21c1bafbf35a84905d604d5d1223801d639cf3ed140bd651c08752
+
   - name: python3-pycparser
     buildsystem: simple
     build-commands:
diff --git a/gajim/common/helpers.py b/gajim/common/helpers.py
index 6fe9956399fb44a5fcfea0d6f39e288540baed4a..870c94a897c5b58c387d0b66e1b6a4fad9f066ac 100644
--- a/gajim/common/helpers.py
+++ b/gajim/common/helpers.py
@@ -56,9 +56,9 @@
 from urllib.parse import unquote
 from io import StringIO
 from datetime import datetime, timedelta
-from distutils.version import LooseVersion as V
 from encodings.punycode import punycode_encode
 from functools import wraps
+from packaging.version import Version as V
 
 from nbxmpp.namespaces import Namespace
 from nbxmpp.const import Role
diff --git a/gajim/gajim.py b/gajim/gajim.py
index e2b2915a2b7e2e4cfc8d21cfead4e962cb9092d3..4184dc139177afed9340c798b5bff20677bfef62 100644
--- a/gajim/gajim.py
+++ b/gajim/gajim.py
@@ -22,7 +22,7 @@
 import platform
 from ctypes import CDLL, byref, create_string_buffer
 from ctypes.util import find_library
-from distutils.version import LooseVersion as V
+from packaging.version import Version as V
 
 from gajim.common import i18n
 
diff --git a/setup.cfg b/setup.cfg
index 27ab82580dc806264245ca38289eb2ba9833de52..bc87994512ba87fa952ef5d16ce4ef725ef91366 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -23,6 +23,7 @@ install_requires =
     css-parser
     keyring
     nbxmpp>=0.9.94
+    packaging
     precis-i18n>=1.0.0
     pyOpenSSL>=16.2
     pycairo>=1.16.0