doorstop-dev / doorstop

Requirements management using version control.
https://doorstop.readthedocs.io
Other
465 stars 126 forks source link

AttributeError: module 'numpy' has no attribute 'float'. #639

Open yahym opened 6 months ago

yahym commented 6 months ago

Before start: Very nice to see this repo alive and thank you for the work 👍

Can you please tell me if there any chance to allow also bigger versions of numpy in the future, to avoid version constraint? Or an issue to openpyxl needs to be raised?

Seems that the exception below is fixed with a constraint in requirements with numpy<1.24.

issue related https://github.com/doorstop-dev/doorstop/issues/609 I do not know if there is any connection, but seems that default openpyxl version coming from doorstop without constraint on numpy version helps to raise this exception:

v2.2.1 - latest doorstop release from pypi was used

2024-02-29T19:40:24.7308982Z Requirement already satisfied: doorstop in d:\tools\actions-runner\_work\_tool\python\3.10.11\x64\lib\site-packages (from -r requirements_docs_dev.txt (line 2)) (2.2.1)

2024-02-29T19:40:24.7449249Z Requirement already satisfied: openpyxl<3.0,>=2.6 in d:\tools\actions-runner\_work\_tool\python\3.10.11\x64\lib\site-packages (from doorstop->-r requirements_docs_dev.txt (line 2)) (2.6.4)

Exception raised:

2024-02-29T19:40:27.4034244Z ##[group]Run doorstop publish -j docs.dev/requirements all _build/requirements
2024-02-29T19:40:27.4034708Z doorstop publish -j docs.dev/requirements all _build/requirements
2024-02-29T19:40:27.4148194Z shell: C:\windows\System32\WindowsPowerShell\v1.0\powershell.EXE -command ". '{0}'"
2024-02-29T19:40:27.4148463Z env:
2024-02-29T19:40:27.4148691Z   pythonLocation: D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64
2024-02-29T19:40:27.4148924Z ##[endgroup]
2024-02-29T19:40:28.3756659Z Traceback (most recent call last):
2024-02-29T19:40:28.3764582Z   File "D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64\lib\runpy.py", line 196, in _run_module_as_main
2024-02-29T19:40:28.3765219Z     return _run_code(code, main_globals, None,
2024-02-29T19:40:28.3766642Z   File "D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64\lib\runpy.py", line 86, in _run_code
2024-02-29T19:40:28.3767028Z     exec(code, run_globals)
2024-02-29T19:40:28.3767684Z   File "D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64\Scripts\doorstop.exe\__main__.py", line 4, in <module>
2024-02-29T19:40:28.3768380Z   File "D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64\lib\site-packages\doorstop\__init__.py", line 8, in <module>
2024-02-29T19:40:28.3771603Z     from doorstop.core import (
2024-02-29T19:40:28.3772551Z   File "D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64\lib\site-packages\doorstop\core\exporter.py", line 10, in <module>
2024-02-29T19:40:28.3774893Z     import openpyxl
2024-02-29T19:40:28.3775535Z   File "D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64\lib\site-packages\openpyxl\__init__.py", line 4, in <module>
2024-02-29T19:40:28.3778145Z     from openpyxl.compat.numbers import NUMPY, PANDAS
2024-02-29T19:40:28.3778828Z   File "D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64\lib\site-packages\openpyxl\compat\__init__.py", line 5, in <module>
2024-02-29T19:40:28.3780862Z     from .strings import (
2024-02-29T19:40:28.3781565Z   File "D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64\lib\site-packages\openpyxl\compat\strings.py", line 10, in <module>
2024-02-29T19:40:28.3784237Z     from .numbers import NUMERIC_TYPES
2024-02-29T19:40:28.3785068Z   File "D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64\lib\site-packages\openpyxl\compat\numbers.py", line 49, in <module>
2024-02-29T19:40:28.3788114Z     numpy.float,
2024-02-29T19:40:28.3788854Z   File "D:\tools\actions-runner\_work\_tool\Python\3.10.11\x64\lib\site-packages\numpy\__init__.py", line 338, in __getattr__
2024-02-29T19:40:28.3794356Z     raise AttributeError(__former_attrs__[attr])
2024-02-29T19:40:28.3794966Z AttributeError: module 'numpy' has no attribute 'float'.
2024-02-29T19:40:28.3795458Z `np.float` was a deprecated alias for the builtin `float`. To avoid this error in existing code, use `float` by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.float64` here.
2024-02-29T19:40:28.3796022Z The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
2024-02-29T19:40:28.3797859Z     https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'cfloat'?
sfrinaldi commented 3 months ago

I actually had this issue. It is primarily a problem with the openpyxl version and I believe if you update it after doing the doorstop install manually for this version you can get it to work. (Just pip install --upgrade openpyxl after installing doorstop) That version of doorstop can work on a later version of openpyxl but a earlier version is called/referenced probably in the pyproject.toml file. You could just edit here potentially but haven't tried that out.

Another solution is the pre-releases address / fix this with the increased support for later versions not only to openpyxl but for python as well I believe. (Pre-release: v3.0b15).