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

ImportError: cannot import name 'np' from 'libpysal.common' #684

Closed
wsqstar opened this issue Feb 5, 2024 · 1 comment
Closed

ImportError: cannot import name 'np' from 'libpysal.common' #684

wsqstar opened this issue Feb 5, 2024 · 1 comment

Comments

@wsqstar
Copy link

wsqstar commented Feb 5, 2024

Platform information:

Last updated: 2024-02-05T17:05:56.848677+08:00

Python implementation: CPython
Python version : 3.12.0
IPython version : 8.21.0

Compiler : GCC 11.2.0
OS : Linux
Release : 5.15.133.1-microsoft-standard-WSL2
Machine : x86_64
Processor : x86_64
CPU cores : 12
Architecture: 64bit

  • SciPy version:1.11.4
  • NumPy version:1.26.3

When following the https://pysal.org/spopt/notebooks/p-median.html
I tried:

import geopandas
import matplotlib.pyplot as plt
from matplotlib.patches import Patch
import matplotlib.lines as mlines
import numpy
import pulp
import shapely
import spopt
from spopt.locate import PMedian, simulated_geo_points

import warnings
with warnings.catch_warnings():
    warnings.simplefilter("ignore")
    # ignore deprecation warning - GH pysal/spaghetti#649
    import spaghetti

%watermark -w
%watermark -iv

However:


ImportError Traceback (most recent call last)
Cell In[7], line 15
13 warnings.simplefilter("ignore")
14 # ignore deprecation warning - GH pysal/spaghetti#649
---> 15 import spaghetti
17 get_ipython().run_line_magic('watermark', '-w')
18 get_ipython().run_line_magic('watermark', '-iv')

File ~/miniconda3/envs/py312/lib/python3.12/site-packages/spaghetti/init.py:7
1 version = "1.6.2"
3 """
4 # spaghetti --- Spatial Graphs: Networks, Topology, & Inference
5 """
----> 7 from .network import Network, PointPattern, SimulatedPointPattern
8 from .network import extract_component, spanning_tree
9 from .network import element_as_gdf, regular_lattice

File ~/miniconda3/envs/py312/lib/python3.12/site-packages/spaghetti/network.py:5
2 from itertools import islice
3 import copy, os, pickle, warnings
----> 5 import esda
6 import numpy
8 from .analysis import GlobalAutoK

File ~/miniconda3/envs/py312/lib/python3.12/site-packages/esda/init.py:12
10 from .geary_local import Geary_Local
11 from .geary_local_mv import Geary_Local_MV
---> 12 from .getisord import G, G_Local
13 from .join_counts import Join_Counts
14 from .join_counts_local import Join_Counts_Local

File ~/miniconda3/envs/py312/lib/python3.12/site-packages/esda/getisord.py:8
5 all = ["G", "G_Local"]
7 import warnings
----> 8 from libpysal.common import np, stats
9 from libpysal.weights.spatial_lag import lag_spatial as slag
10 from libpysal.weights.util import fill_diagonal

ImportError: cannot import name 'np' from 'libpysal.common' (/home/myubuntu/miniconda3/envs/py312/lib/python3.12/site-packages/libpysal/common.py)

@martinfleis
Copy link
Member

Please update esda to v2.5.1 which resolved this issue.

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

2 participants