Skip to content

AttributeError: module 'scipy.spatial._qhull' has no attribute '__pyx_capi__' #46

Open
@ogrisel

Description

@ogrisel

Description

It is not possible to import scipy.interpolate in a jupyterlite deployment with the xeus-python kernel and packages from the https://repo.mamba.pm/emscripten-forge repo.

Reproduce

  1. Create a new xeus-python-demo deployment using the template
  2. Edit the environment.yml file to add scikit-learn (just scipy is probably enough)
  3. Enable GitHub Pages deployment
  4. Here is such a deployment: https://ogrisel.github.io/xeus-python-sklearn-demo/lab/index.html
  5. Go to the deployed jupyterlite URL, create a new xeus-python notebook and import scipy.interpolate in it.
  6. You should get the following exception:
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[3], line 1
----> 1 import scipy.interpolate

File /lib/python3.11/site-packages/scipy/interpolate/__init__.py:167
      1 """
      2 ========================================
      3 Interpolation (:mod:`scipy.interpolate`)
   (...)
    165 (should not be used in new code).
    166 """
--> 167 from ._interpolate import *
    168 from ._fitpack_py import *
    170 # New interface to fitpack library:

File /lib/python3.11/site-packages/scipy/interpolate/_interpolate.py:16
     14 from ._polyint import _Interpolator1D
     15 from . import _ppoly
---> 16 from .interpnd import _ndim_coords_from_arrays
     17 from ._bsplines import make_interp_spline, BSpline
     20 def lagrange(x, w):

File interpnd.pyx:1, in init scipy.interpolate.interpnd()

AttributeError: module 'scipy.spatial._qhull' has no attribute '__pyx_capi__'

Note that I cannot reproduce the problem when importing scipy.interpolate in a local XPython kernel (using regular jupyterlab instead of jupyterlite).

Note that the JS console complains about a 404 error when attempting to fetch:

https://ogrisel.github.io/xeus-python-sklearn-demo/api/contents/lib/python3.11/site-packages/scipy/interpolate/all.json

So it looks like a packaging problem to me.

Expected behavior

scipy should be importable and usable.

Context

  • JupyterLite version: 0.4.5
  • Operating System and version: macOS 15.1.1
  • Browser and version: firefox or chrome, does not matter.
Browser Output
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data [serverconnection.js:90:24](webpack://_JUPYTERLAB.CORE_OUTPUT/node_modules/@jupyterlab/services/lib/serverconnection.js)
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data [serverconnection.js:90:24](webpack://_JUPYTERLAB.CORE_OUTPUT/node_modules/@jupyterlab/services/lib/serverconnection.js)
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data [serverconnection.js:90:24](webpack://_JUPYTERLAB.CORE_OUTPUT/node_modules/@jupyterlab/services/lib/serverconnection.js)
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data [serverconnection.js:90:24](webpack://_JUPYTERLAB.CORE_OUTPUT/node_modules/@jupyterlab/services/lib/serverconnection.js)
XHRGET
https://ogrisel.github.io/xeus-python-sklearn-demo/api/contents/lib/python3.11/site-packages/scipy/interpolate/all.json
[HTTP/2 404  22ms]

don't worry, about SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data... nothing's broken. If there had been a
file at https://ogrisel.github.io/xeus-python-sklearn-demo/api/contents/lib/python3.11/site-packages/scipy/interpolate/all.json, you might see some more files. contents.js:724:24
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data serverconnection.js:90:24
Could not resolve location of /lib/python3.11/site-packages/scipy/interpolate/init.py on server registry.js:317:28
Path resolution bailing: does not exist renderers.js:824:24
SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data serverconnection.js:90:24
Could not resolve location of /lib/python3.11/site-packages/scipy/interpolate/_interpolate.py on server registry.js:317:28
Path resolution bailing: does not exist renderers.js:824:24

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions