2023年3月29日 星期三

Python 3.11 安裝 Scrapy 出現 Failed building wheel for twisted-iocpsupport 錯誤

我在 ThinkPad 筆電上安裝 Scrapy 前面都沒問題, 但最後一步卻出現 "Failed building wheel for twisted-iocpsupport" 錯誤 : 

Building wheels for collected packages: twisted-iocpsupport
  Building wheel for twisted-iocpsupport (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for twisted-iocpsupport (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [5 lines of output]
      running bdist_wheel
      running build
      running build_ext
      building 'twisted_iocpsupport.iocpsupport' 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 twisted-iocpsupport
Failed to build twisted-iocpsupport
ERROR: Could not build wheels for twisted-iocpsupport, which is required to install pyproject.toml-based projects

爬文發現這可能與 Python 3.11 有關, 這版本太新了, 建議是安裝 3.6~3.10 的 Python : 


"This error occurs because twisted-iocpsupport is not supported by python 3.11 Consider going back to any versions between 3.6 and 3.10 that fixed the problem for me. Go to twisted-iocpsupport documentation and see the versions of python it supports"

不過錯誤訊息中提到, 程序是在安裝  'twisted_iocpsupport.iocpsupport'  擴充工具時出錯, 建議到微軟下載 Visual Studio C++ 建立工具 : 


雖然下載的檔案很小 (約 3MB), 但真正執行後選擇安裝 C++ 編譯工具集卻要下載安裝高達 8GB 的程式 : 






這麼大我看還是算了, 我對 Anaconda 這種 400MB 級的軟體都不想安裝了, 何況這 8GB 的, 反正現在也沒在用 Scrapy, 以後要用到時再安裝唄.

PS : 直接用 pip install twisted-iocpsupport 安裝也是出現同樣的錯誤訊息.

沒有留言 :