diff --git a/param/parameterized.py b/param/parameterized.py index 975ed840..57703ae4 100644 --- a/param/parameterized.py +++ b/param/parameterized.py @@ -26,7 +26,7 @@ # Allow this file to be used standalone if desired, albeit without JSON serialization try: from . import serializer -except ImportError: +except ModuleNotFoundError: serializer = None from collections import defaultdict, namedtuple, OrderedDict @@ -67,7 +67,7 @@ try: from .ipython import ParamPager, ipython_async_executor as async_executor param_pager = ParamPager(metaclass=True) # Generates param description - except ImportError: + except ModuleNotFoundError: from ._utils import async_executor else: from ._utils import async_executor diff --git a/param/version.py b/param/version.py index 34b86b54..5f62ff95 100644 --- a/param/version.py +++ b/param/version.py @@ -519,7 +519,7 @@ def get_setupcfg_version(): """ try: import configparser - except ImportError: + except ModuleNotFoundError: import ConfigParser as configparser # python2 (also prevents dict-like access) import re cfg = "setup.cfg" diff --git a/tests/testcomparator.py b/tests/testcomparator.py index 92d4e90f..20faf522 100644 --- a/tests/testcomparator.py +++ b/tests/testcomparator.py @@ -7,11 +7,11 @@ try: import numpy as np -except ImportError: +except ModuleNotFoundError: np = None try: import pandas as pd -except ImportError: +except ModuleNotFoundError: pd = None _now = datetime.datetime.now() diff --git a/tests/testdateparam.py b/tests/testdateparam.py index 298a4e6e..e0ca5e36 100644 --- a/tests/testdateparam.py +++ b/tests/testdateparam.py @@ -11,7 +11,7 @@ try: import numpy as np -except ImportError: +except ModuleNotFoundError: np = None from .utils import check_defaults diff --git a/tests/testdaterangeparam.py b/tests/testdaterangeparam.py index e86778f4..6fb43a5e 100644 --- a/tests/testdaterangeparam.py +++ b/tests/testdaterangeparam.py @@ -12,7 +12,7 @@ try: import numpy as np -except ImportError: +except ModuleNotFoundError: np = None # Assuming tests of range parameter cover most of what's needed to diff --git a/tests/testdefaults.py b/tests/testdefaults.py index fc14c319..8cad0104 100644 --- a/tests/testdefaults.py +++ b/tests/testdefaults.py @@ -23,11 +23,11 @@ try: import numpy # noqa -except ImportError: +except ModuleNotFoundError: skip.append('Array') try: import pandas # noqa -except ImportError: +except ModuleNotFoundError: skip.append('DataFrame') skip.append('Series') diff --git a/tests/testfiledeserialization.py b/tests/testfiledeserialization.py index b00f1e8e..adf4fcc0 100644 --- a/tests/testfiledeserialization.py +++ b/tests/testfiledeserialization.py @@ -20,19 +20,19 @@ pd_ver = pd.__version__.split('.') df = pd.DataFrame({'A':[1,2,3], 'B':[1.1,2.2,3.3]}) modern_pd = pd if (int(pd_ver[0]) >= 1 and int(pd_ver[1]) >= 2) else None -except ImportError: +except ModuleNotFoundError: pd = df1 = df2 = modern_pd = None # The writer could be xlsxwriter, but the sufficient condition is the presence of # openpyxl try: import openpyxl as xlsxm -except ImportError: +except ModuleNotFoundError: xlsxm = None try: import odf as ods -except ImportError: +except ModuleNotFoundError: ods = None # prior to pandas version 1.2, xlrd was always the default excel reader (though it @@ -42,27 +42,27 @@ import xlrd as xls if int(xls.__version__.split('.')[0]) > 2: raise Exception() -except ImportError: +except ModuleNotFoundError: if modern_pd is None: xlsxm = None try: import pyarrow.feather as feather -except ImportError: +except ModuleNotFoundError: feather = None try: import fastparquet as parquet -except ImportError: +except ModuleNotFoundError: parquet = None try: import pyarrow as parquet -except ImportError: +except ModuleNotFoundError: pass try: import tables as hdf5 -except ImportError: +except ModuleNotFoundError: hdf5 = None np_skip = skipIf(np is None, "NumPy is not available") diff --git a/tests/testipythonmagic.py b/tests/testipythonmagic.py index 2a1e68da..9c9a2e4f 100644 --- a/tests/testipythonmagic.py +++ b/tests/testipythonmagic.py @@ -9,7 +9,7 @@ try: import IPython # noqa -except ImportError: +except ModuleNotFoundError: import os if os.getenv('PARAM_TEST_IPYTHON','0') == '1': raise ImportError("PARAM_TEST_IPYTHON=1 but ipython not available.") diff --git a/tests/testjsonserialization.py b/tests/testjsonserialization.py index 103f3cba..e11dc63c 100644 --- a/tests/testjsonserialization.py +++ b/tests/testjsonserialization.py @@ -11,7 +11,7 @@ try: from jsonschema import validate, ValidationError -except ImportError: +except ModuleNotFoundError: import os if os.getenv('PARAM_TEST_JSONSCHEMA','0') == '1': raise ImportError("PARAM_TEST_JSONSCHEMA=1 but jsonschema not available.") @@ -25,7 +25,7 @@ ndarray = np.array([[1,2,3],[4,5,6]]) npdt1 = np.datetime64(now) npdt2 = np.datetime64(after_now) -except ImportError: +except ModuleNotFoundError: np, ndarray, npdt1, npdt2 = None, None, None, None np_skip = skipIf(np is None, "NumPy is not available") @@ -36,7 +36,7 @@ df2 = pd.DataFrame({'A':[1.1,2.2,3.3], 'B':[1.1,2.2,3.3]}) pdts1 = pd.Timestamp(now) pdts2 = pd.Timestamp(after_now) -except ImportError: +except ModuleNotFoundError: pd, df1, df2, pdts1, pdts2 = None, None, None, None, None pd_skip = skipIf(pd is None, "pandas is not available") diff --git a/tests/testnumberparameter.py b/tests/testnumberparameter.py index a796d2e7..56f2d34c 100644 --- a/tests/testnumberparameter.py +++ b/tests/testnumberparameter.py @@ -10,7 +10,7 @@ try: import numpy as np -except ImportError: +except ModuleNotFoundError: np = None class TestNumberParameters(unittest.TestCase): diff --git a/tests/testnumpy.py b/tests/testnumpy.py index 9367e058..3bc47d25 100644 --- a/tests/testnumpy.py +++ b/tests/testnumpy.py @@ -11,7 +11,7 @@ try: import numpy import numpy.testing -except ImportError: +except ModuleNotFoundError: if os.getenv('PARAM_TEST_NUMPY','0') == '1': raise ImportError("PARAM_TEST_NUMPY=1 but numpy not available.") else: diff --git a/tests/testpandas.py b/tests/testpandas.py index 38134e22..6227cded 100644 --- a/tests/testpandas.py +++ b/tests/testpandas.py @@ -12,7 +12,7 @@ try: import pandas -except ImportError: +except ModuleNotFoundError: if os.getenv('PARAM_TEST_PANDAS','0') == '1': raise ImportError("PARAM_TEST_PANDAS=1 but pandas not available.") else: diff --git a/tests/testpickle.py b/tests/testpickle.py index 31fc8c64..cafe0d76 100644 --- a/tests/testpickle.py +++ b/tests/testpickle.py @@ -5,15 +5,15 @@ try: import cloudpickle -except ImportError: +except ModuleNotFoundError: cloudpickle = None try: import numpy as np -except ImportError: +except ModuleNotFoundError: np = None try: import pandas as pd -except ImportError: +except ModuleNotFoundError: pd = None diff --git a/tests/testreactive.py b/tests/testreactive.py index 68e6b9ee..c4fff0f1 100644 --- a/tests/testreactive.py +++ b/tests/testreactive.py @@ -7,7 +7,7 @@ try: import numpy as np -except ImportError: +except ModuleNotFoundError: if os.getenv('PARAM_TEST_NUMPY','0') == '1': raise ImportError("PARAM_TEST_NUMPY=1 but numpy not available.") else: @@ -15,7 +15,7 @@ try: import pandas as pd -except ImportError: +except ModuleNotFoundError: if os.getenv('PARAM_TEST_PANDAS','0') == '1': raise ImportError("PARAM_TEST_PANDAS=1 but pandas not available.") else: diff --git a/tests/testtimedependent.py b/tests/testtimedependent.py index d77a66e9..85cdeadd 100644 --- a/tests/testtimedependent.py +++ b/tests/testtimedependent.py @@ -13,7 +13,7 @@ try: import gmpy -except ImportError: +except ModuleNotFoundError: import os if os.getenv('PARAM_TEST_GMPY','0') == '1': raise ImportError("PARAM_TEST_GMPY=1 but gmpy not available.") diff --git a/tests/testtupleparam.py b/tests/testtupleparam.py index 3fa5e415..15f2905b 100644 --- a/tests/testtupleparam.py +++ b/tests/testtupleparam.py @@ -8,7 +8,7 @@ try: import numpy as np -except ImportError: +except ModuleNotFoundError: np = None diff --git a/tests/testutils.py b/tests/testutils.py index 4fbe2eda..d060a314 100644 --- a/tests/testutils.py +++ b/tests/testutils.py @@ -14,12 +14,12 @@ try: import numpy as np -except ImportError: +except ModuleNotFoundError: np = None try: import pandas as pd -except ImportError: +except ModuleNotFoundError: pd = None now = dt.datetime.now()