Skip to content
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

[bug] AttributeError: module 'numpy' has no attribute 'int' #494

Open
niziak opened this issue Sep 23, 2024 · 3 comments
Open

[bug] AttributeError: module 'numpy' has no attribute 'int' #494

niziak opened this issue Sep 23, 2024 · 3 comments
Labels

Comments

@niziak
Copy link

niziak commented Sep 23, 2024

Describe the bug

Cannot install due to numpy incompatibility with networkx.
AttributeError: module 'numpy' has no attribute 'int'

Ansible role openwisp.openwisp2 version 22.5.3

RUNNING HANDLER [openwisp.openwisp2 : migrate timeseries database] ***************************************************************************************************************************
task path: /home/niziak/.ansible/roles/openwisp.openwisp2/handlers/main.yml:22
redirecting (type: modules) ansible.builtin.django_manage to community.general.django_manage
redirecting (type: modules) ansible.builtin.django_manage to community.general.django_manage

fatal: [openwisp.lan.spox.org]: FAILED! =>

{
  "changed":false,
  "cmd":[
    "./manage.py",
    "migrate_timeseries"
  ],
  "msg":":stderr: 
Traceback (most recent call last):
  File \"/opt/openwisp2/./manage.py\", line 10, in <module>\n    execute_from_command_line(sys.argv)
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/django/core/management/__init__.py\", line 419, in execute_from_command_line\n    utility.execute()
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/django/core/management/__init__.py\", line 395, in execute
    django.setup()\n  File \"/opt/openwisp2/env/lib/python3.11/site-packages/django/__init__.py\", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/django/apps/registry.py\", line 114, in populate
    app_config.import_models()
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/django/apps/config.py\", line 301, in import_models
    self.models_module = import_module(models_module_name)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/usr/lib/python3.11/importlib/__init__.py\", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"<frozen importlib._bootstrap>\", line 1206, in _gcd_import
  File \"<frozen importlib._bootstrap>\", line 1178, in _find_and_load
  File \"<frozen importlib._bootstrap>\", line 1149, in _find_and_load_unlocked
  File \"<frozen importlib._bootstrap>\", line 690, in _load_unlocked
  File \"<frozen importlib._bootstrap_external>\", line 940, in exec_module
  File \"<frozen importlib._bootstrap>\", line 241, in _call_with_frames_removed
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/openwisp_network_topology/models.py\", line 6, in <module>
    from .base.topology import AbstractTopology
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/openwisp_network_topology/base/topology.py\", line 12, in <module>
    from netdiff import NetJsonParser, diff
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/netdiff/__init__.py\", line 2, in <module>
    from .parsers.batman import BatmanParser  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/netdiff/parsers/batman.py\", line 2, in <module>
    from .base import BaseParser
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/netdiff/parsers/base.py\", line 4, in <module>
    import networkx
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/networkx/__init__.py\", line 115, in <module>
    import networkx.readwrite
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/networkx/readwrite/__init__.py\", line 15, in <module>
    from networkx.readwrite.graphml import *
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/networkx/readwrite/graphml.py\", line 314, in <module>
    class GraphML(object):
  File \"/opt/openwisp2/env/lib/python3.11/site-packages/networkx/readwrite/graphml.py\", line 346, in GraphML
    (np.int, \"int\"), (np.int8, \"int\"),
     ^^^^^^
  File \"/usr/lib/python3/dist-packages/numpy/__init__.py\", line 305, in __getattr__
    raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:\n    https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations. Did you mean: 'inf'?
",
  "path":"/opt/openwisp2/env/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "syspath":[
    "/tmp/ansible_django_manage_payload_z25qg24_/ansible_django_manage_payload.zip",
    "/usr/lib/python311.zip",
    "/usr/lib/python3.11",
    "/usr/lib/python3.11/lib-dynload",
    "/usr/local/lib/python3.11/dist-packages",
    "/usr/lib/python3/dist-packages",
    "/usr/lib/python3.11/dist-packages"
  ]
}

Steps To Reproduce

  1. On fresh LXC Debian 12
  2. Try to install using latest ansible role

Expected behavior
venv is used so all packages should have pinned or bounded versions to prevent such problems.

When numpy is downgraded in venv:

/opt/openwisp2/env/bin/pip install numpy==1.23.5

then ansible role can be started again and everything works.

@niziak niziak added the bug label Sep 23, 2024
@nemesifier
Copy link
Member

Try with the latest master, the latest released version is not compatible with Debian 12.

@supersebbo
Copy link

Same error, Debian 12. Did you resolve this by using Master?

@nemesifier
Copy link
Member

Same error, Debian 12. Did you resolve this by using Master?

The 22.05 release is not compatible with Debian 12. Use the development version as already suggested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants