Could not build wheels for dependency-injector, which is required to install pyproject.toml-based projects

  Kiến thức lập trình

I’m installing “dependency-injector” package for my project. But it keeps showing error like below

(env) PS C:Multi-Participants_Survey_Project-main-2djangosurveybackend> pip install dependency-injector
Collecting dependency-injector
  Using cached dependency-injector-4.41.0.tar.gz (913 kB)
  Preparing metadata (setup.py) ... done
Collecting six<=1.16.0,>=1.7.0 (from dependency-injector)
  Using cached six-1.16.0-py2.py3-none-any.whl (11 kB)
Building wheels for collected packages: dependency-injector
  Building wheel for dependency-injector (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [54 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating buildlib.win32-cpython-312
      creating buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injectorerrors.py -> buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injectorresources.py -> buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injectorschema.py -> buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injectorwiring.py -> buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injector__init__.py -> buildlib.win32-cpython-312dependency_injector
      creating buildlib.win32-cpython-312dependency_injectorext
      copying srcdependency_injectorextaiohttp.py -> buildlib.win32-cpython-312dependency_injectorext
      copying srcdependency_injectorextflask.py -> buildlib.win32-cpython-312dependency_injectorext
      copying srcdependency_injectorext__init__.py -> buildlib.win32-cpython-312dependency_injectorext
      copying srcdependency_injectorcontainers.pyi -> buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injectorproviders.pyi -> buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injector__init__.pyi -> buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injectorpy.typed -> buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injectorcontainers.pxd -> buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injectorproviders.pxd -> buildlib.win32-cpython-312dependency_injector
      copying srcdependency_injectorextaiohttp.pyi -> buildlib.win32-cpython-312dependency_injectorext
      copying srcdependency_injectorextflask.pyi -> buildlib.win32-cpython-312dependency_injectorext
      copying srcdependency_injectorext__init__.pyi -> buildlib.win32-cpython-312dependency_injectorext
      running build_ext
      building 'dependency_injector.containers' extension
      creating buildtemp.win32-cpython-312
      creating buildtemp.win32-cpython-312Release
      creating buildtemp.win32-cpython-312Releasesrc
      creating buildtemp.win32-cpython-312Releasesrcdependency_injector
      "C:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.38.33130binHostX86x86cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DCYTHON_CLINE_IN_TRACEBACK=0 -IC:Multi-Participants_Survey_Project-main-2djangosurveybackendenvinclude -IC:UserstrulyAppDataLocalProgramsPythonPython312include -IC:UserstrulyAppDataLocalProgramsPythonPython312Include "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.38.33130include" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCAuxiliaryVSinclude" "-IC:Program Files (x86)Windows Kits10include10.0.22621.0ucrt" "-IC:Program Files (x86)Windows Kits10\include10.0.22621.0\um" "-IC:Program Files (x86)Windows Kits10\include10.0.22621.0\shared" "-IC:Program Files (x86)Windows Kits10\include10.0.22621.0\winrt" "-IC:Program Files (x86)Windows Kits10\include10.0.22621.0\cppwinrt" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCToolsMSVC14.38.33130include" "-IC:Program FilesMicrosoft Visual Studio2022CommunityVCAuxiliaryVSinclude" "-IC:Program Files (x86)Windows Kits10include10.0.22621.0ucrt" "-IC:Program Files (x86)Windows Kits10\include10.0.22621.0\um" "-IC:Program Files (x86)Windows Kits10\include10.0.22621.0\shared" "-IC:Program Files (x86)Windows Kits10\include10.0.22621.0\winrt" "-IC:Program Files (x86)Windows Kits10\include10.0.22621.0\cppwinrt" /Tcsrc/dependency_injector/containers.c /Fobuildtemp.win32-cpython-312Releasesrc/dependency_injector/containers.obj -O2
      containers.c
      src/dependency_injector/containers.c(33558): error C2039: 'curexc_traceback': is not a member of '_ts'
      C:UserstrulyAppDataLocalProgramsPythonPython312includecpython/pystate.h(115): note: see declaration of '_ts'
      src/dependency_injector/containers.c(33561): error C2039: 'curexc_traceback': is not a member of '_ts'
      C:UserstrulyAppDataLocalProgramsPythonPython312includecpython/pystate.h(115): note: see declaration of '_ts'
      src/dependency_injector/containers.c(34184): warning C4013: '_PyUnicode_Ready' undefined; assuming extern returning int
      src/dependency_injector/containers.c(36123): error C2039: 'gi_code': is not a member of 'PyGenObject'
      C:UserstrulyAppDataLocalProgramsPythonPython312includecpython/genobject.h(31): note: see declaration of 'PyGenObject'
      src/dependency_injector/containers.c(36123): error C2039: 'gi_code': is not a member of 'PyGenObject'
      C:UserstrulyAppDataLocalProgramsPythonPython312includecpython/genobject.h(31): note: see declaration of 'PyGenObject'
      src/dependency_injector/containers.c(37417): error C2039: 'ob_digit': is not a member of '_longobject'
      C:UserstrulyAppDataLocalProgramsPythonPython312includecpython/longintrepr.h(87): note: see declaration of '_longobject'
      src/dependency_injector/containers.c(38290): error C2039: 'ob_digit': is not a member of '_longobject'
      C:UserstrulyAppDataLocalProgramsPythonPython312includecpython/longintrepr.h(87): note: see declaration of '_longobject'
      src/dependency_injector/containers.c(38345): error C2039: 'ob_digit': is not a member of '_longobject'
      C:UserstrulyAppDataLocalProgramsPythonPython312includecpython/longintrepr.h(87): note: see declaration of '_longobject'
      src/dependency_injector/containers.c(38486): error C2039: 'ob_digit': is not a member of '_longobject'
      C:UserstrulyAppDataLocalProgramsPythonPython312includecpython/longintrepr.h(87): note: see declaration of '_longobject'
      src/dependency_injector/containers.c(38541): error C2039: 'ob_digit': is not a member of '_longobject'
      C:UserstrulyAppDataLocalProgramsPythonPython312includecpython/longintrepr.h(87): note: see declaration of '_longobject'
      src/dependency_injector/containers.c(39078): error C2039: 'ob_digit': is not a member of '_longobject'
      C:UserstrulyAppDataLocalProgramsPythonPython312includecpython/longintrepr.h(87): note: see declaration of '_longobject'
      error: command 'C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\bin\HostX86\x86\cl.exe' failed with exit code 2
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for dependency-injector
  Running setup.py clean for dependency-injector
Failed to build dependency-injector
ERROR: Could not build wheels for dependency-injector, which is required to install pyproject.toml-based projects

I don’t know if it’s related to my current Python version (3.12).Can anyone helps me with a solution, on how to fix this ?

I tried to download related packages by pip install wheel, pip install pyproject-toml, pip install aiohttp but still failed to download dependency-injector. I even change the download command to pip3 install dependency-injector and pip install dependency-injector==4.41.0, but none of them works

LEAVE A COMMENT