Skip to content

Pyomo is not compatible with Numpy 2.0.0 #3290

@JeanWi

Description

@JeanWi

Summary

Pyomo is not compatible with numpy 2.0.0 as np.float_ was removed.
From the numpy release note: Alias np.float_ has been removed. Use np.float64 instead. (https://github.com/numpy/numpy/releases/tag/v2.0.0)

Steps to reproduce the issue

Installing the latest numpy (2.0.0) and using pyomo leads to the following error:
AttributeError: np.float_ was removed in the NumPy 2.0 release. Use np.float64 instead.. Did you mean: 'float16'?

The problem is caused in: pyomo\common\dependencies.py:1002

Error Message

C:\hostedtoolcache\windows\Python\3.12.3\x64\Lib\site-packages\pyomo\common\dependencies.py:475: in exec_module
deferred.resolve()
C:\hostedtoolcache\windows\Python\3.12.3\x64\Lib\site-packages\pyomo\common\dependencies.py:334: in resolve
self._module, self._available = _perform_import(
C:\hostedtoolcache\windows\Python\3.12.3\x64\Lib\site-packages\pyomo\common\dependencies.py:768: in _perform_import
callback(module, True)
C:\hostedtoolcache\windows\Python\3.12.3\x64\Lib\site-packages\pyomo\common\dependencies.py:1002: in finalize_numpy
floats = [np.float, np.float16, np.float32, np.float64]
C:\hostedtoolcache\windows\Python\3.12.3\x64\Lib\site-packages\numpy_init
.py:411: in getattr
raise AttributeError(
E AttributeError: np.float_ was removed in the NumPy 2.0 release. Use np.float64 instead.. Did you mean: 'float16'?


### Information on your system

Pyomo version: 6.7.3
Python version: 3.12
Operating system: Windows 11
How Pyomo was installed (PyPI, conda, source): PyPI
Solver (if applicable): gurobi, but not applicable


### Additional information

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions