|
49 | 49 | which = "where" if os.name == "nt" else "which" |
50 | 50 |
|
51 | 51 | # the first available solver will be the default solver |
52 | | -with contextlib.suppress(ImportError): |
| 52 | +with contextlib.suppress(ModuleNotFoundError): |
53 | 53 | import gurobipy |
54 | 54 |
|
55 | 55 | available_solvers.append("gurobi") |
56 | | -with contextlib.suppress(ImportError): |
| 56 | +with contextlib.suppress(ModuleNotFoundError): |
57 | 57 | _new_highspy_mps_layout = None |
58 | 58 | import highspy |
59 | 59 |
|
|
72 | 72 | if sub.run([which, "cbc"], stdout=sub.DEVNULL, stderr=sub.STDOUT).returncode == 0: |
73 | 73 | available_solvers.append("cbc") |
74 | 74 |
|
75 | | -with contextlib.suppress(ImportError): |
| 75 | +with contextlib.suppress(ModuleNotFoundError): |
76 | 76 | import pyscipopt as scip |
77 | 77 |
|
78 | 78 | available_solvers.append("scip") |
79 | | -with contextlib.suppress(ImportError): |
| 79 | + |
| 80 | +with contextlib.suppress(ModuleNotFoundError): |
80 | 81 | import cplex |
81 | 82 |
|
82 | 83 | available_solvers.append("cplex") |
83 | | -with contextlib.suppress(ImportError): |
| 84 | + |
| 85 | +with contextlib.suppress(ModuleNotFoundError): |
84 | 86 | import xpress |
85 | 87 |
|
86 | 88 | available_solvers.append("xpress") |
87 | | -with contextlib.suppress(ImportError): |
| 89 | + |
| 90 | +with contextlib.suppress(ModuleNotFoundError): |
88 | 91 | import mosek |
89 | 92 |
|
90 | 93 | with contextlib.suppress(mosek.Error): |
|
95 | 98 |
|
96 | 99 | available_solvers.append("mosek") |
97 | 100 |
|
98 | | -with contextlib.suppress(ImportError): |
| 101 | +with contextlib.suppress(ModuleNotFoundError): |
99 | 102 | import mindoptpy |
100 | 103 |
|
101 | 104 | available_solvers.append("mindopt") |
102 | | -with contextlib.suppress(ImportError): |
| 105 | + |
| 106 | +with contextlib.suppress(ModuleNotFoundError): |
103 | 107 | import coptpy |
104 | 108 |
|
105 | 109 | with contextlib.suppress(coptpy.CoptError): |
|
0 commit comments