Skip to content

Upgrade numpy (v1.23.5) to prevent depricated distutils error in Python 3.12+ #2678

@aliphys

Description

@aliphys

I'm trying to set up a study environment for d2l in uv. Python 3.12 (Windows 10) leads to an error, since there is a dependency on distutils by numpy 1.23.5, which was signaled as deprecated in PyTorch (PEP 632).

'numpy==1.23.5',

pyproject.toml file

[project]
name = "d2l-study"
version = "0.1.0"
description = "Dive into Deep Learning study environment (notebooks + vendored d2l)"
requires-python = ">=3.8,<3.12"
# d2l relies on depricated (from 3.12) pkgutil.ImImporter class.
# See: https://github.com/d2l-ai/d2l-en/issues/2659#issuecomment-3230737568

# Core runtime dependencies you will likely need; adjust as you go.
dependencies = [
    "jupyter>=1.0.0",
    "ipykernel>=6.0.0",
    "numpy>=1.23",
    "pandas>=2.0",
    "matplotlib>=3.7",
    "torch>=2.0,
    "d2l==1.0.3",  # install from PyPI
]

[build-system]
requires = ["hatchling>=1.0.0"]
build-backend = "hatchling.build"

[tool.uv]
# This project is notebook-oriented and not meant to be
# installed as a package, so disable packaging for the root.
package = false

uv sync with requires-python = ">=3.8"

PS C:\Users\user\Documents\GitHub\d2l_study> uv sync
Using CPython 3.13.5
Creating virtual environment at: .venv
Resolved 142 packages in 1.80s                                                                                                                                                
  × Failed to build `numpy==1.23.5`
  ├─▶ The build backend returned an error
  ╰─▶ Call to `setuptools.build_meta:__legacy__.build_wheel` failed (exit code: 1)                                                                                                                                                                                                                                                                                [stderr]                                                                                                                                                                
      Traceback (most recent call last):                                                                                                                                      
        File "<string>", line 8, in <module>                                                                                                                                  
          from setuptools.build_meta import __legacy__ as backend                                                                                                             
        File "C:\Users\user\AppData\Local\uv\cache\builds-v0\.tmprLnFwf\Lib\site-packages\setuptools\__init__.py", line 10, in <module>                                       
          import distutils.core                                                                                                                                               
      ModuleNotFoundError: No module named 'distutils'                                                                                                                                                                                                                                                                                                            hint: `distutils` was removed from the standard library in Python 3.12. Consider adding a constraint (like `numpy >1.23.5`) to avoid building a version of `numpy`      
      that depends on `distutils`.                                                                                                                                            
  help: `numpy` (v1.23.5) was included because `d2l-study` (v0.1.0) depends on `numpy`       

uv sync with requires-python = ">=3.8,<3.12"

PS C:\Users\user\Documents\GitHub\d2l_study> uv sync                                                                                                                          
Using CPython 3.10.18                                                                                                                                                         
Removed virtual environment at: .venv
Creating virtual environment at: .venv
Resolved 226 packages in 2.81s
Prepared 20 packages in 44.82s
Installed 120 packages in 14.51s
 + anyio==4.12.1                                                                                                                                                              
 + argon2-cffi==25.1.0                                                                                                                                                        
 + argon2-cffi-bindings==25.1.0                                                                                                                                               
 + arrow==1.4.0                                                                                                                                                               
 + asttokens==3.0.1                                                                                                                                                           
 + async-lru==2.0.5                                                                                                                                                           
 + attrs==25.4.0                                                                                                                                                              
 + babel==2.17.0                                                                                                                                                              
 + beautifulsoup4==4.14.3
 + bleach==6.3.0
 + certifi==2026.1.4
 + cffi==2.0.0
 + charset-normalizer==3.4.4
 + colorama==0.4.6
 + comm==0.2.3
 + contourpy==1.3.2
 + cycler==0.12.1
 + d2l==1.0.3
 + debugpy==1.8.19
 + decorator==5.2.1
 + defusedxml==0.7.1
 + exceptiongroup==1.3.1
 + executing==2.2.1
 + fastjsonschema==2.21.2
 + filelock==3.20.3
 + fonttools==4.61.1
 + fqdn==1.5.1
 + fsspec==2026.1.0
 + h11==0.16.0
 + httpcore==1.0.9
 + httpx==0.28.1
 + idna==3.11
 + ipykernel==7.1.0
 + ipython==8.38.0
 + ipython-pygments-lexers==1.1.1
 + ipywidgets==8.1.8
 + isoduration==20.11.0
 + jedi==0.19.2
 + jinja2==3.1.6
 + json5==0.13.0
 + jsonpointer==3.0.0
 + jsonschema==4.26.0
 + jsonschema-specifications==2025.9.1
 + jupyter==1.0.0
 + jupyter-client==8.8.0
 + jupyter-console==6.6.3
 + jupyter-core==5.9.1
 + jupyter-events==0.12.0
 + jupyter-lsp==2.3.0
 + jupyter-server==2.17.0
 + jupyter-server-terminals==0.5.3
 + jupyterlab==4.5.2
 + jupyterlab-pygments==0.3.0
 + jupyterlab-server==2.28.0
 + jupyterlab-widgets==3.0.16
 + kiwisolver==1.4.9
 + lark==1.3.1
 + markupsafe==3.0.3
 + matplotlib==3.7.2
 + matplotlib-inline==0.1.6
 + mistune==3.2.0
 + mpmath==1.3.0
 + nbclient==0.10.4
 + nbconvert==7.16.6
 + nbformat==5.10.4
 + nest-asyncio==1.6.0
 + networkx==3.4.2
 + notebook==7.5.2
 + notebook-shim==0.2.4
 + numpy==1.23.5
 + overrides==7.7.0
 + packaging==25.0
 + pandas==2.0.3
 + pandocfilters==1.5.1
 + parso==0.8.5
 + pillow==12.1.0
 + platformdirs==4.5.1
 + prometheus-client==0.24.0
 + prompt-toolkit==3.0.52
 + psutil==7.2.1
 + pure-eval==0.2.3
 + pycparser==2.23
 + pygments==2.19.2
 + pyparsing==3.0.9
 + python-dateutil==2.9.0.post0
 + python-json-logger==4.0.0
 + pytz==2025.2
 + pywinpty==3.0.2
 + pyyaml==6.0.3
 + pyzmq==27.1.0
 + qtconsole==5.7.0
 + qtpy==2.4.3
 + referencing==0.37.0
 + requests==2.31.0
 + rfc3339-validator==0.1.4
 + rfc3986-validator==0.1.1
 + rfc3987-syntax==1.1.0
 + rpds-py==0.30.0
 + scipy==1.10.1
 + send2trash==2.0.0
 + setuptools==80.9.0
 + six==1.17.0
 + soupsieve==2.8.1
 + stack-data==0.6.3
 + sympy==1.14.0
 + terminado==0.18.1
 + tinycss2==1.4.0
 + tomli==2.4.0
 + torch==2.9.1
 + tornado==6.5.4
 + traitlets==5.14.3
 + typing-extensions==4.15.0
 + tzdata==2025.3
 + uri-template==1.3.0
 + urllib3==2.6.3
 + wcwidth==0.2.14
 + webcolors==25.10.0
 + webencodings==0.5.1
 + websocket-client==1.9.0
 + widgetsnbextension==4.0.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions