0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Python 3.11ではwordcloudが使用できず3.9でしか動作しなかった件

Posted at

目的・経緯

  • wordcloudを使いたかったので私用PCにPythonを入れて試そうとしたらハマった
  • 何も考えずにPythonは最新のものを使用した(ここがハマったポイント)

前提条件・利用環境

  • Windows 11 Home 22H2(64bit)
  • Python 3.11.1-amd64.exe

発生事象

  • pip install wordcloudでエラーが発生
    • 最初のエラーはVisual Studioがインストールされてない
    • Visual Studioインストール後に再度試したところ、以下のエラーが発生
C:\Users\asanok>pip install wordcloud
Collecting wordcloud
  Using cached wordcloud-1.8.2.2.tar.gz (220 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy>=1.6.1 in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from wordcloud) (1.24.2)
Requirement already satisfied: pillow in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from wordcloud) (9.4.0)
Requirement already satisfied: matplotlib in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from wordcloud) (3.7.1)
Requirement already satisfied: contourpy>=1.0.1 in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from matplotlib->wordcloud) (1.0.7)
Requirement already satisfied: cycler>=0.10 in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from matplotlib->wordcloud) (0.11.0)
Requirement already satisfied: fonttools>=4.22.0 in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from matplotlib->wordcloud) (4.39.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from matplotlib->wordcloud) (1.4.4)
Requirement already satisfied: packaging>=20.0 in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from matplotlib->wordcloud) (23.0)
Requirement already satisfied: pyparsing>=2.3.1 in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from matplotlib->wordcloud) (3.0.9)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from matplotlib->wordcloud) (2.8.2)
Requirement already satisfied: six>=1.5 in c:\users\asanok\appdata\local\programs\python\python311\lib\site-packages (from python-dateutil>=2.7->matplotlib->wordcloud) (1.16.0)
Installing collected packages: wordcloud
  DEPRECATION: wordcloud is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
  Running setup.py install for wordcloud ... error
  error: subprocess-exited-with-error

  × Running setup.py install for wordcloud did not run successfully.
  │ exit code: 1
  ╰─> [28 lines of output]
      running install
      C:\Users\asanok\AppData\Local\Programs\Python\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-cpython-311
      creating build\lib.win-amd64-cpython-311\wordcloud
      copying wordcloud\color_from_image.py -> build\lib.win-amd64-cpython-311\wordcloud
      copying wordcloud\tokenization.py -> build\lib.win-amd64-cpython-311\wordcloud
      copying wordcloud\wordcloud.py -> build\lib.win-amd64-cpython-311\wordcloud
      copying wordcloud\wordcloud_cli.py -> build\lib.win-amd64-cpython-311\wordcloud
      copying wordcloud\_version.py -> build\lib.win-amd64-cpython-311\wordcloud
      copying wordcloud\__init__.py -> build\lib.win-amd64-cpython-311\wordcloud
      copying wordcloud\__main__.py -> build\lib.win-amd64-cpython-311\wordcloud
      copying wordcloud\stopwords -> build\lib.win-amd64-cpython-311\wordcloud
      copying wordcloud\DroidSansMono.ttf -> build\lib.win-amd64-cpython-311\wordcloud
      UPDATING build\lib.win-amd64-cpython-311\wordcloud/_version.py
      set build\lib.win-amd64-cpython-311\wordcloud/_version.py to '1.8.2.2'
      running build_ext
      building 'wordcloud.query_integral_image' extension
      creating build\temp.win-amd64-cpython-311
      creating build\temp.win-amd64-cpython-311\Release
      creating build\temp.win-amd64-cpython-311\Release\wordcloud
      "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -IC:\Users\asanok\AppData\Local\Programs\Python\Python311\include -IC:\Users\asanok\AppData\Local\Programs\Python\Python311\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.35.32215\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\VS\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.22000.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.22000.0\\cppwinrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.8\include\um" /Tcwordcloud/query_integral_image.c /Fobuild\temp.win-amd64-cpython-311\Release\wordcloud/query_integral_image.obj
      query_integral_image.c
      wordcloud/query_integral_image.c(196): fatal error C1083: include ファイルを開けません。'longintrepr.h':No such file or directory
      error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x64\\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: legacy-install-failure

× Encountered error while trying to install package.
╰─> wordcloud

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.

[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: python.exe -m pip install --upgrade pip

C:\Users\asanok>
  • エラー箇所:
    • wordcloud/query_integral_image.c(196): fatal error C1083: include ファイルを開けません。'longintrepr.h':No such file or directory
    • エラー内容を検索の結果、この記事でPython3.11ではなく3.9を入れれば問題が回避できると判明
  • 当面の目標であるwordcloudが動けば、最新のPython3.11である必要はなかったためこのままwordcloudを使用することにした

まとめ・注意事項

  • wordcloudを使うためにVisual Studio(「C++によるデスクトップ開発」のコンポーネント)が必要
  • 同様に、現時点ではwordcloudはPython3.11では動作しない模様
  • 一時的な回避策としてPython3.9をインストールすることでwordcloudが問題なく動作した
  • 本記事の各使用ソフトウェアついては各ソフトウェア権者に帰属します
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?