前提・実現したいこと
pythonのwordcloudを使って
文章を可視化しようと試みてます
発生している問題・エラーメッセージ
wordcloudを使ったソースコードを作成しました。
実行するためにwordcloudのインストール
$pip install wordcloud
のコマンド実行時に以下のエラーがでてしまい
wordcloudのインストールができない状況です。
Running setup.py install for wordcloud ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\username\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\username\AppData\Local\Temp\pip-install-31oenvfa\wordcloud\setup.py'"'"'; file='"'"'C:\Users\username\AppData\Local\Temp\pip-install-31oenvfa\wordcloud\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\username\AppData\Local\Temp\pip-record-alvwf8yo\install-record.txt' --single-version-externally-managed --compile
cwd: C:\Users\username\AppData\Local\Temp\pip-install-31oenvfa\wordcloud
Complete output (22 lines):
c:\users\username\appdata\local\programs\python\python37-32\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'test_requires'
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build\lib.win32-3.7
creating build\lib.win32-3.7\wordcloud
copying wordcloud\color_from_image.py -> build\lib.win32-3.7\wordcloud
copying wordcloud\tokenization.py -> build\lib.win32-3.7\wordcloud
copying wordcloud\wordcloud.py -> build\lib.win32-3.7\wordcloud
copying wordcloud\wordcloud_cli.py -> build\lib.win32-3.7\wordcloud
copying wordcloud_version.py -> build\lib.win32-3.7\wordcloud
copying wordcloud_init_.py -> build\lib.win32-3.7\wordcloud
copying wordcloud_main_.py -> build\lib.win32-3.7\wordcloud
copying wordcloud\stopwords -> build\lib.win32-3.7\wordcloud
copying wordcloud\DroidSansMono.ttf -> build\lib.win32-3.7\wordcloud
UPDATING build\lib.win32-3.7\wordcloud/_version.py
set build\lib.win32-3.7\wordcloud/_version.py to '1.5.0'
running build_ext
building 'wordcloud.query_integral_image' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\username\appdata\local\programs\python\python37-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\username\AppData\Local\Temp\pip-install-31oenvfa\wordcloud\setup.py'"'"'; file='"'"'C:\Users\username\AppData\Local\Temp\pip-install-31oenvfa\wordcloud\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record 'C:\Users\username\AppData\Local\Temp\pip-record-alvwf8yo\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
該当のソースコード
#!/usr/bin/env python3 # -*- coding:utf-8 -*- from os import path from PIL import Image from wordcloud import WordCloud #, STOPWORDS import numpy as np import matplotlib.pyplot as plt # カレントディレクトリの設定 d = path.dirname(__file__) # WordCloudに渡す文章 text = "This article is about the sandwich. For the meat served as part of such a sandwich, see Patty. For other uses, see Hamburger (disambiguation).Hamburger RedDot Burger.jpg Hamburger with french fries and a beer Course Main course Place of origin United States or Germany disputed Created by Multiple claims (see text) Serving temperature Hot Main ingredients Ground meat, bread Cookbook: Hamburger Media: Hamburger A hamburger, beefburger or burger is a sandwich consisting of one or more cooked patties of ground meat, usually beef, placed inside a sliced bread roll or bun. The patty may be pan fried, grilled, or flame broiled. Hamburgers are often served with cheese, lettuce, tomato, onion, pickles, bacon, or chiles; condiments such as ketchup, mayonnaise, mustard, relish, or special sauce and are frequently placed on sesame seed buns. A hamburger topped with cheese is called a cheeseburger. The term burger can also be applied to the meat patty on its own, especially in the United Kingdom, where the term patty is rarely used, or the term can even refer simply to ground beef. The term may be prefixed with the type of meat or meat substitute used, as in turkey burger, bison burger, or veggie burger Hamburgers are sold at fast-food restaurants, diners, and specialty and high-end restaurants (where burgers may sell for several times the cost of a fast-food burger, but may be one of the cheaper options on the menu). There are many international and regional variations of the hamburger." # 元画像の指定 alice_mask = np.array(Image.open(path.join(d, "alice_mask.png"))) # WordCloudのパラメーター設定 wc = WordCloud( background_color = "white", max_words = 2000, mask = alice_mask, ) # WordCloudの実行 wc.generate(text) # 生成した画像をファイルとして出力 wc.to_file(path.join(d, "alice.png")) print("終了しました")
試したこと
anacondaでwordcloudをインストールや
エラー文面に関係あるBuild Tools for Visual Studio 2019をインストールして
再度$pip install wordcloud
を実行してみましたが正しくインストールできずにエラーとなりました。
補足情報(FW/ツールのバージョンなど)
環境はwindows10
python ver:3.7.5
あなたの回答
tips
プレビュー