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

AttributeError: module 'numpy' has no attribute 'long' #623

Open
sarah-blanchette opened this issue Nov 1, 2023 · 8 comments
Open

AttributeError: module 'numpy' has no attribute 'long' #623

sarah-blanchette opened this issue Nov 1, 2023 · 8 comments

Comments

@sarah-blanchette
Copy link

sarah-blanchette commented Nov 1, 2023

Input:

from libpysal import weights 

Output:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-39-1dedce384da8> in <module>
----> 1 from libpysal import weights, examples

[~/opt/anaconda3/lib/python3.8/site-packages/libpysal/__init__.py](https://file+.vscode-resource.vscode-cdn.net/Users/sarahblanchette/BSQ_201/Pasqal/~/opt/anaconda3/lib/python3.8/site-packages/libpysal/__init__.py) in <module>
     25 from importlib.metadata import PackageNotFoundError, version
     26 
---> 27 from . import cg, examples, io, weights
     28 
     29 with contextlib.suppress(PackageNotFoundError):

[~/opt/anaconda3/lib/python3.8/site-packages/libpysal/cg/__init__.py](https://file+.vscode-resource.vscode-cdn.net/Users/sarahblanchette/BSQ_201/Pasqal/~/opt/anaconda3/lib/python3.8/site-packages/libpysal/cg/__init__.py) in <module>
      9 from .sphere import *
     10 from .voronoi import *
---> 11 from .alpha_shapes import *

[~/opt/anaconda3/lib/python3.8/site-packages/libpysal/cg/alpha_shapes.py](https://file+.vscode-resource.vscode-cdn.net/Users/sarahblanchette/BSQ_201/Pasqal/~/opt/anaconda3/lib/python3.8/site-packages/libpysal/cg/alpha_shapes.py) in <module>
     14 from scipy import sparse
     15 
---> 16 from ..common import requires, jit, HAS_JIT
     17 
     18 if not HAS_JIT:
...
--> 320         raise AttributeError("module {!r} has no attribute "
    321                              "{!r}".format(__name__, attr))
    322 

AttributeError: module 'numpy' has no attribute 'long'

I also have the same issue when importing Momepy

@jGaboardi
Copy link
Member

@sarah-blanchette Please provide the following information as stated in the issue template:

  • Platform information:
>>> import os; print(os.name, os.sys.platform);print(os.uname())
  • Python version:
>>> import sys; print(sys.version)
  • SciPy version:
>>> import scipy; print(scipy.__version__)
  • NumPy version:
>>> import numpy; print(numpy.__version__)

Also, please provide the versions of libpysal and momepy you are running and how they were installed (pip, conda, etc.).

@jGaboardi
Copy link
Member

Locally, I am not seeing any problems:

Python 3.12.0 | packaged by conda-forge | (main, Oct  3 2023, 08:43:38) [Clang 15.0.7 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.16.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import libpysal

In [2]: from libpysal import weights

In [3]: libpysal.__version__
Out[3]: '4.8.0'

@sarah-blanchette
Copy link
Author

Here it is. I'm thinking it has to do with the Numpy version, but I had to downgrade it for another library. Also I used pip to install pysal

os name and platform: posix darwin
os uname: posix.uname_result(sysname='Darwin', nodename='MacBook-Air-93.local', release='22.5.0', version='Darwin Kernel Version 22.5.0: Mon Apr 24 20:52:43 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T8112', machine='x86_64')
sys: 3.8.3 (default, Jul 2 2020, 11:26:31)
[Clang 10.0.0 ]
scipy: 1.10.1
numpy: 1.24.4

@jGaboardi
Copy link
Member

  • What version of libpysal and momepy are you running?
  • Did you install pysal or libpysal?

@sarah-blanchette
Copy link
Author

libpysal: (4.8.0)
momepy: (0.6.0)

I installed both libpysal and pysal

@jGaboardi
Copy link
Member

Hmmm. OK. pip is the troublemaker more often than not in there kinds of scenarios. I would suggest try to create your environment again entirely from conda-forge.

Testing are passing on oldest environment we support, where numpy=1.22.4, and the latest, where numpy=1.26.0. So it probably isn't an issue with numpy itself.

@martinfleis
Copy link
Member

This may be related to the numba version. Can you please post full Traceback? Not the truncated one? It is unclear where the long is being called as that happens where the ... is.

@jGaboardi
Copy link
Member

'm thinking it has to do with the Numpy version, but I had to downgrade it for another library

Also, which is the "other library?" Is it numba as @martinfleis suggested?

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

No branches or pull requests

3 participants