2024年1月29日 星期一

在 Python v3.12 安裝 line-bot-sdk 套件出現 Failed building wheel for multidict 錯誤的問題

今天持續測試 Line Bot, 進展到安裝 Line Messaging API 的開發套件 line-bot-sdk 時出現 "Failed building wheel for multidict" 的錯誤訊息 : 

D:\python\flask>pip install line-bot-sdk    
Collecting line-bot-sdk
  Using cached line_bot_sdk-3.7.0-py2.py3-none-any.whl.metadata (13 kB)
Collecting requests==2.31.0 (from line-bot-sdk)
  Using cached requests-2.31.0-py3-none-any.whl.metadata (4.6 kB)
Collecting urllib3<3,>=2.0.5 (from line-bot-sdk)
  Using cached urllib3-2.1.0-py3-none-any.whl.metadata (6.4 kB)
Collecting aiohttp==3.9.1 (from line-bot-sdk)
  Using cached aiohttp-3.9.1-cp312-cp312-win_amd64.whl.metadata (7.6 kB)
Collecting future (from line-bot-sdk)
  Using cached future-0.18.3-py3-none-any.whl
Collecting pydantic<3,>=2.0.3 (from line-bot-sdk)
  Using cached pydantic-2.5.3-py3-none-any.whl.metadata (65 kB)
Collecting aenum>=3.1.11 (from line-bot-sdk)
  Using cached aenum-3.1.15-py3-none-any.whl.metadata (3.7 kB)
Collecting python-dateutil>=2.5.3 (from line-bot-sdk)
  Using cached python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
Collecting Deprecated (from line-bot-sdk)
  Using cached Deprecated-1.2.14-py2.py3-none-any.whl.metadata (5.4 kB)
Collecting attrs>=17.3.0 (from aiohttp==3.9.1->line-bot-sdk)
  Using cached attrs-23.2.0-py3-none-any.whl.metadata (9.5 kB)
Collecting multidict<7.0,>=4.5 (from aiohttp==3.9.1->line-bot-sdk)
  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==3.9.1->line-bot-sdk)
  Using cached yarl-1.9.4-cp312-cp312-win_amd64.whl.metadata (32 kB)
Collecting frozenlist>=1.1.1 (from aiohttp==3.9.1->line-bot-sdk)
  Using cached frozenlist-1.4.1-cp312-cp312-win_amd64.whl.metadata (12 kB)
Collecting aiosignal>=1.1.2 (from aiohttp==3.9.1->line-bot-sdk)
  Using cached aiosignal-1.3.1-py3-none-any.whl (7.6 kB)
Collecting charset-normalizer<4,>=2 (from requests==2.31.0->line-bot-sdk)
  Using cached charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl.metadata (34 kB)
Collecting idna<4,>=2.5 (from requests==2.31.0->line-bot-sdk)
  Using cached idna-3.6-py3-none-any.whl.metadata (9.9 kB)
Collecting certifi>=2017.4.17 (from requests==2.31.0->line-bot-sdk)
  Using cached certifi-2023.11.17-py3-none-any.whl.metadata (2.2 kB)
Collecting annotated-types>=0.4.0 (from pydantic<3,>=2.0.3->line-bot-sdk)
  Using cached annotated_types-0.6.0-py3-none-any.whl.metadata (12 kB)
Collecting pydantic-core==2.14.6 (from pydantic<3,>=2.0.3->line-bot-sdk)
  Using cached pydantic_core-2.14.6-cp312-none-win_amd64.whl.metadata (6.6 kB)
Collecting typing-extensions>=4.6.1 (from pydantic<3,>=2.0.3->line-bot-sdk)
  Using cached typing_extensions-4.9.0-py3-none-any.whl.metadata (3.0 kB)
Requirement already satisfied: six>=1.5 in c:\users\tony1\appdata\local\programs\python\python312\lib\site-packages (from python-dateutil>=2.5.3->line-bot-sdk) (1.16.0)
Collecting wrapt<2,>=1.10 (from Deprecated->line-bot-sdk)
  Using cached wrapt-1.16.0-cp312-cp312-win_amd64.whl.metadata (6.8 kB)
Using cached line_bot_sdk-3.7.0-py2.py3-none-any.whl (748 kB)
Using cached aiohttp-3.9.1-cp312-cp312-win_amd64.whl (362 kB)
Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Using cached aenum-3.1.15-py3-none-any.whl (137 kB)
Using cached pydantic-2.5.3-py3-none-any.whl (381 kB)
Using cached pydantic_core-2.14.6-cp312-none-win_amd64.whl (1.9 MB)
Using cached urllib3-2.1.0-py3-none-any.whl (104 kB)
Using cached Deprecated-1.2.14-py2.py3-none-any.whl (9.6 kB)
Using cached annotated_types-0.6.0-py3-none-any.whl (12 kB)
Using cached attrs-23.2.0-py3-none-any.whl (60 kB)
Using cached certifi-2023.11.17-py3-none-any.whl (162 kB)
Using cached charset_normalizer-3.3.2-cp312-cp312-win_amd64.whl (100 kB)
Using cached frozenlist-1.4.1-cp312-cp312-win_amd64.whl (50 kB)
Using cached idna-3.6-py3-none-any.whl (61 kB)
Using cached typing_extensions-4.9.0-py3-none-any.whl (32 kB)
Using cached wrapt-1.16.0-cp312-cp312-win_amd64.whl (37 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
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-312
      creating build\lib.win-amd64-cpython-312\multidict
      copying multidict\_abc.py -> build\lib.win-amd64-cpython-312\multidict
      copying multidict\_compat.py -> build\lib.win-amd64-cpython-312\multidict
      copying multidict\_multidict_base.py -> build\lib.win-amd64-cpython-312\multidict
      copying multidict\_multidict_py.py -> build\lib.win-amd64-cpython-312\multidict
      copying multidict\__init__.py -> build\lib.win-amd64-cpython-312\multidict
      running egg_info
      writing multidict.egg-info\PKG-INFO
      writing dependency_links to multidict.egg-info\dependency_links.txt
      writing top-level names to multidict.egg-info\top_level.txt
      reading manifest file 'multidict.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no previously-included files matching '*.pyc' found anywhere in distribution
      warning: no previously-included files found matching 'multidict\_multidict.html'
      warning: no previously-included files found matching 'multidict\*.so'
      warning: no previously-included files found matching 'multidict\*.pyd'
      warning: no previously-included files found matching 'multidict\*.pyd'
      no previously-included directories found matching 'docs\_build'
      adding license file 'LICENSE'
      writing manifest file 'multidict.egg-info\SOURCES.txt'
      C:\Users\tony1\AppData\Local\Temp\pip-build-env-jkzgbslr\overlay\Lib\site-packages\setuptools\command\build_py.py:207: _Warning: Package 'multidict._multilib' is absent from the `packages` configuration.
      !!

              ********************************************************************************
              ############################
              # Package would be ignored #
              ############################
              Python recognizes 'multidict._multilib' as an importable package[^1],
              but it is absent from setuptools' `packages` configuration.

              This leads to an ambiguous overall configuration. If you want to distribute this
              package, please make sure that 'multidict._multilib' is explicitly added
              to the `packages` configuration field.

              Alternatively, you can also rely on setuptools' discovery methods
              (for example by using `find_namespace_packages(...)`/`find_namespace:`
              instead of `find_packages(...)`/`find:`).

              You can read more about "package discovery" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

              If you don't want 'multidict._multilib' to be distributed and are
              already explicitly excluding 'multidict._multilib' via
              `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
              you can try to use `exclude_package_data`, or `include-package-data=False` in
              combination with a more fine grained `package-data` configuration.

              You can read more about "package data files" on setuptools documentation page:

              - https://setuptools.pypa.io/en/latest/userguide/datafiles.html


              [^1]: For Python, any directory (with suitable naming) can be imported,
                    even if it does not contain any `.py` files.
                    On the other hand, currently there is no concept of package data
                    directory, all directories are treated like packages.
              ********************************************************************************

      !!
        check.warn(importable)
      copying multidict\__init__.pyi -> build\lib.win-amd64-cpython-312\multidict
      copying multidict\py.typed -> build\lib.win-amd64-cpython-312\multidict
      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

這些訊息令人一頭霧水, 似乎是與沒有安裝 Visual C++ 有關, 我搜尋到下面這篇文章, 發現有可能是 Python 版本的問題 : 


我從回覆訊息中讀到有人從舊 Python 版本升版至 v3.12 時也出現此問題 : 




我的本機 Python 版本剛好就是 v3.12 : 

C:\Users\tony1>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.

檢查 Thonny 自帶的 Python 版本是 v3.10, 在 Thonny 安裝 line-bot-sdk 就完全沒問題. 可見版本最新不見得最好用啊!

沒有留言 :