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

Module import errors when using Jupyter Book 'Interact' feature (ESDA notebook as a start) #88

Closed
jeffcsauer opened this issue Mar 21, 2020 · 1 comment

Comments

@jeffcsauer
Copy link

jeffcsauer commented Mar 21, 2020

Hi all,

Was copy-editing the PySAL Notebooks (https://pysal.org/notebooks/intro) and encountered semi-regular import errors when trying to run the Notebooks via 'Interact' feature of Jupyter Book. For example, on the first esda notebook Spatial_Autocorrelation_for_Areal_Unit_Data), the first chunk enouncters an error when trying to import relevant modules:

import sys
import os
sys.path.append(os.path.abspath('..'))
from pysal.explore import esda

ModuleNotFoundError Traceback (most recent call last)
in
2 import os
3 sys.path.append(os.path.abspath('..'))
----> 4 from pysal.explore import esda

/opt/conda/lib/python3.7/site-packages/pysal/init.py in
1 version = '2.2.1'
----> 2 from . import lib
3 from . import explore
4 from . import viz
5 from . import model

/opt/conda/lib/python3.7/site-packages/pysal/lib/init.py in
26 """
27
---> 28 from libpysal import cg
29 from libpysal import io
30 from libpysal import weights

ModuleNotFoundError: No module named 'libpysal'

A quick reinstall and alternative loading of esda & libpysal allows the notebook to be run without error once a few import lines are edited throughout the notebook:

# Add these commands to top of notebook
!pip install esda
import esda as esda
!pip install libpysal
import libpysal as lps 

Remove:

from pysal.explore import esda #from second chunk
import pysal.lib as lps #from third chunk
from pysal.explore import esda #from ~20th chunk
from pysal.explore import esda #from ~35th chunk

Lastly, change:
from pysal.viz import mapclassify as mc to import mapclassify as mc

Is this issue due to a setting in Jupyter Book or Binder? Or simply some import commands that needed to be updated?

@jeffcsauer jeffcsauer changed the title Small import error when interacting with ESDA notebook Module import errors when using Jupyter Book 'Interact' feature (ESDA notebook as a start) Mar 21, 2020
@jeffcsauer
Copy link
Author

jeffcsauer commented Mar 24, 2020

Will be fixed with #86

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

1 participant