-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pyomo is not compatible with Numpy 2.0.0 #3290
Comments
Thanks for working on this! My conda environment just broke yesterday when I rebuilt my environment and it picked up numpy 2 automatically. However, I'm working from a pinned version of pyomo due to conflicts with other packages in my project and won't be able to take advantage of this fix in the latest pyomo version when it is released. I can pin numpy manually in my requirements, but to help others avoid the same issue, is it possible to also update the dependency version requirements of past pyomo versions so that conda, pip, and other package managers know that previous versions of pyomo require numpy<2? |
Hi, @jasonmbray-p66 - A couple of notes:
|
Just my luck that my current project is pinned to <= 6.7.1, so I just barely missed the updated pins! Thanks for considering my request. |
I just installed the latest version of Pyomo and it pulled numpy 2.0 (Numpy without any pinned version was needed a package that also needs .) So, pinning did not seem to work. I have a theory about this. Citing setup.py of the most recent release, you find (a lot of lines omitted) setup_kwargs = dict(
python_requires='>=3.8',
install_requires=['ply'],
extras_require={
'optional': [
'numpy<2.0.0',
],
},
) that it declares "numpy<2.0.0" as an optional dependency. So, if another package has |
for now, pyomo does not work with numpy 2 and its optional linking dependency is not enforced. See here: Pyomo/pyomo#3290 (comment)
for now, pyomo does not work with numpy 2 and its optional linking dependency is not enforced. See here: Pyomo/pyomo#3290 (comment)
Note for all tracking this:
|
I got the same issue while using Numpy v2.0.1 along with the most recent release v6.7.3, and got to circumvent the issue by adding the lines below import numpy as np before importing Pyomo |
The next release (6.7.4) will have this issue resolved. |
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. Usenp.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. Usenp.float64
instead.. Did you mean: 'float16'?The text was updated successfully, but these errors were encountered: