Search code examples
pythonpipaiohttp

Please find the cause of "Could not build wheels for multidict, which is required to install pyproject.toml-based projects" - Error


I was just trying to install aiohttp in python. So I just typed in console like that: pip install aiohttp . At first, the installation went well, but finally I got the following Error.

C:\Users\1\AppData\Local\Programs\Python\Python312\Scripts>pip3 install aiohttp
Collecting aiohttp
  Obtaining dependency information for aiohttp from https://files.pythonhosted.org/packages/4e/13/e929a6a50288e60ade3961b294d2f5aeb251b6579e4290a5397e484d0df9/aiohttp-3.9.1-cp312-cp312-win_amd64.whl.metadata
 ...   ...
Using cached frozenlist-1.4.1-cp312-cp312-win_amd64.whl (50 kB)
Using cached yarl-1.9.4-cp312-cp312-win_amd64.whl (76 kB)
Building wheels for collected packages: multidict
  Building wheel for multidict (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for multidict (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [74 lines of output]
      *********************
      * Accelerated build *
      *********************
      running bdist_wheel
 ...   ...
      running build_ext
      building 'multidict._multidict' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

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

[notice] A new release of pip is available: 23.2.1 -> 23.3.2
[notice] To update, run: C:\Users\1\AppData\Local\Programs\Python\Python312\python.exe -m pip install --upgrade pip

So I tried the another one "pip install pyproject". But I can't solve. Please help me!


Solution

  • EDIT

    As of February the 1st 2024, multidict released a wheel for Python 3.12.

    You can download it here, but it will also be updated over the coming days in the affected libraries. aiohttp as an example updated theirs today (02-02-2024).

    END OF EDIT

    I just had this problem and despite the other answer, aiohttp does have Python 3.12 wheels, so it should work.

    This is how I solved it (for Windows using VS Code):

    Download the Microsoft C++ Build Tools as provided in the link: https://visualstudio.microsoft.com/visual-cpp-build-tools/

    enter image description here

    Click Download Build Tools and run it as administrator.

    Accept terms and wait for it to download and install.

    Select the Individual components pane and click off:

    enter image description here

    • Windows Universal C Runtime
    • C++ Build Tools core features
    • C++ 2022 Redistributable Update
    • C++ CMake tools for Windows
    • MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest)

    For Windows 10:

    Windows 10 SDK (Pick newest version)

    For Windows 11:

    Windows 11 SDK (Pick newest version)

    Click install and wait for it to finish.

    Restart Windows or try to restart VS Code and rerun the pip install aiohttp.

    Output after installing the above and running pip install:

    Defaulting to user installation because normal site-packages is not writeable
    Collecting aiohttp
      Using cached aiohttp-3.9.3-cp312-cp312-win_amd64.whl.metadata (7.6 kB)
    Collecting aiosignal>=1.1.2 (from aiohttp)
      Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
    Collecting attrs>=17.3.0 (from aiohttp)
      Using cached attrs-23.2.0-py3-none-any.whl.metadata (9.5 kB)
    Collecting frozenlist>=1.1.1 (from aiohttp)
      Using cached frozenlist-1.4.1-cp312-cp312-win_amd64.whl.metadata (12 kB)
    Collecting multidict<7.0,>=4.5 (from aiohttp)
      Using cached multidict-6.0.4.tar.gz (51 kB)
      Installing build dependencies ... done
      Getting requirements to build wheel ... done
      Installing backend dependencies ... done
      Preparing metadata (pyproject.toml) ... done
    Collecting yarl<2.0,>=1.0 (from aiohttp)
      Using cached yarl-1.9.4-cp312-cp312-win_amd64.whl.metadata (32 kB)
    Collecting idna>=2.0 (from yarl<2.0,>=1.0->aiohttp)
      Using cached idna-3.6-py3-none-any.whl.metadata (9.9 kB)
    Using cached aiohttp-3.9.3-cp312-cp312-win_amd64.whl (363 kB)
    Using cached attrs-23.2.0-py3-none-any.whl (60 kB)
    Using cached frozenlist-1.4.1-cp312-cp312-win_amd64.whl (50 kB)
    Using cached yarl-1.9.4-cp312-cp312-win_amd64.whl (76 kB)
    Using cached idna-3.6-py3-none-any.whl (61 kB)
    Building wheels for collected packages: multidict
      Building wheel for multidict (pyproject.toml) ... done
      Created wheel for multidict: filename=multidict-6.0.4-cp312-cp312-win_amd64.whl size=28177 sha256=0f82cc586f78a9e5c78ff9464e110da133cfe3a8636e7abf5e32b432113654e7
      Stored in directory: c:\users\m89237\appdata\local\pip\cache\wheels\f6\d8\ff\3c14a64b8f2ab1aa94ba2888f5a988be6ab446ec5c8d1a82da
    Successfully built multidict
    Installing collected packages: multidict, idna, frozenlist, attrs, yarl, aiosignal, aiohttp
    Successfully installed aiohttp-3.9.3 aiosignal-1.3.1 attrs-23.2.0 frozenlist-1.4.1 idna-3.6 multidict-6.0.4 yarl-1.9.4
    

    Import test:

    PS C:\Users\m89237\OneDrive\BACKUP\Python> python
    Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import aiohttp
    >>>