0

I am trying to visualise data using word cloud. However when I used pip install wordcloud, I got the following error:

D:\...>pip install wordcloud
Collecting wordcloud
  Using cached wordcloud-1.8.1.tar.gz (220 kB)
Requirement already satisfied: numpy>=1.6.1 in c:\users\ameli\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from wordcloud) (1.19.5
)
Requirement already satisfied: pillow in c:\users\ameli\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from wordcloud) (8.1.0)
Requirement already satisfied: matplotlib in c:\users\ameli\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from wordcloud) (3.3.3)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\ameli\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from matplotlib
->wordcloud) (2.8.1)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\ameli\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from matplotlib->w
ordcloud) (1.3.1)
Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.3 in c:\users\ameli\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packa
ges (from matplotlib->wordcloud) (2.4.7)
Requirement already satisfied: cycler>=0.10 in c:\users\ameli\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from matplotlib->wordcl
oud) (0.10.0)
Requirement already satisfied: six in c:\users\ameli\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from cycler>=0.10->matplotlib->w
ordcloud) (1.15.0)
Using legacy 'setup.py install' for wordcloud, since package 'wheel' is not installed.
Installing collected packages: wordcloud
    Running setup.py install for wordcloud ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\ameli\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ameli\\Ap
pData\\Local\\Temp\\pip-install-i40_agzl\\wordcloud_591db346adc745a0a41bcad116c4a453\\setup.py'"'"'; __file__='"'"'C:\\Users\\ameli\\AppData\\Local\\Temp\\pip-install-i40_agzl\\wordcloud_591db346adc745a0a41bc
ad116c4a453\\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\ameli\AppData\Local\Temp\pip-record-odcy4xrk\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\ameli\AppData\Local\Packages\PythonSoftwareFo
undation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Include\wordcloud'
         cwd: C:\Users\ameli\AppData\Local\Temp\pip-install-i40_agzl\wordcloud_591db346adc745a0a41bcad116c4a453\
    Complete output (20 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.9
    creating build\lib.win-amd64-3.9\wordcloud
    copying wordcloud\color_from_image.py -> build\lib.win-amd64-3.9\wordcloud
    copying wordcloud\tokenization.py -> build\lib.win-amd64-3.9\wordcloud
    copying wordcloud\wordcloud.py -> build\lib.win-amd64-3.9\wordcloud
    copying wordcloud\wordcloud_cli.py -> build\lib.win-amd64-3.9\wordcloud
    copying wordcloud\_version.py -> build\lib.win-amd64-3.9\wordcloud
    copying wordcloud\__init__.py -> build\lib.win-amd64-3.9\wordcloud
    copying wordcloud\__main__.py -> build\lib.win-amd64-3.9\wordcloud
    copying wordcloud\stopwords -> build\lib.win-amd64-3.9\wordcloud
    copying wordcloud\DroidSansMono.ttf -> build\lib.win-amd64-3.9\wordcloud
    UPDATING build\lib.win-amd64-3.9\wordcloud/_version.py
    set build\lib.win-amd64-3.9\wordcloud/_version.py to '1.8.1'
    running build_ext
    building 'wordcloud.query_integral_image' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\ameli\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\python.exe' -u -c 'import sys, setuptools, tokenize; sys.ar
gv[0] = '"'"'C:\\Users\\ameli\\AppData\\Local\\Temp\\pip-install-i40_agzl\\wordcloud_591db346adc745a0a41bcad116c4a453\\setup.py'"'"'; __file__='"'"'C:\\Users\\ameli\\AppData\\Local\\Temp\\pip-install-i40_agzl
\\wordcloud_591db346adc745a0a41bcad116c4a453\\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\ameli\AppData\Local\Temp\pip-record-odcy4xrk\install-record.txt' --single-version-externally-managed --user --prefix= --compile --install-headers 'C:\Users\ameli\AppDat
a\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Include\wordcloud' Check the logs for full command output.
Wynter Rose
  • 33
  • 1
  • 5
  • 3
    Try to follow the instructions in this part of the error: `error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/` – Shir Mar 09 '21 at 12:27
  • You could also try to install `wheel`: `pip install wheel` – Rafael-WO Mar 09 '21 at 12:29
  • Does this answer your question? [How to install package "wordcloud" in python?](https://stackoverflow.com/questions/61389885/how-to-install-package-wordcloud-in-python) – Jsandesu Mar 09 '21 at 12:29
  • @Shir I have installed Visual Studio so not sure what to do. Its also suggesting C++ which I'm confused about. – Wynter Rose Mar 09 '21 at 12:33
  • @Raf_W-O I have tried and it still produces the same error. – Wynter Rose Mar 09 '21 at 12:33
  • @WynterRose which version of Visual Studio did you install? – Shir Mar 09 '21 at 12:35
  • It is possible you don't have the newwest version of C++ in your visual studio installation. Try to download the build tools from [this link](https://visualstudio.microsoft.com/visual-cpp-build-tools/) and run the .exe file. Let me know if this works for you – Shir Mar 09 '21 at 12:38
  • @Shir thank you, seems to have solved the issue. – Wynter Rose Mar 09 '21 at 14:37
  • @WynterRose you're welcome! It seems that other libraries that require C++ introduce similar errors (see [this link](https://stackoverflow.com/questions/29846087/microsoft-visual-c-14-0-is-required-unable-to-find-vcvarsall-bat)). Anyway, I added a formal solution that you can mark as an accepted answer. – Shir Mar 09 '21 at 14:44

3 Answers3

5

Wordcloud is not a pure Python project as it has some C code. C code needs to be built for different operating systems and Python versions. Normally when you run pip install wordcloud, pip tries to find a built package (aka wheel) for your OS and Python but if it can't find, it downloads the source code and tries to build (compile) it. But this process obviously requires a C compiler which is not supposed to be in a Python developer's system.

I built the package for several configurations and made them public. You can directly install from there. For example if you use Windows and Python 3.10, run pip install https://github.com/sulunemre/word_cloud/releases/download/2/wordcloud-0.post1+gd8241b5-cp310-cp310-win_amd64.whl

Emre
  • 933
  • 15
  • 27
  • I got this error: `ERROR: wordcloud-0.post1+gd8241b5-cp310-cp310-win_amd64.whl is not a supported wheel on this platform.` I am using anaconda python. – SCool Jun 27 '22 at 10:47
1

As mentioned in comments, downloading the build tools from this link and running the .exe file solved the problem.

Shir
  • 1,571
  • 2
  • 9
  • 27
0

Installing wordcloud for python

Wordcloud installation throws error if not satified any of these steps:

  1. Installing the dependencies of wordcloud : matplotlib, pillow, numpy, pandas
  2. Checking for version of Python used
  3. Checking for version of operating system
  4. Checking for version of wordcloud satisfying the version of Python and operating system used

Missing to check version of wordcloud satisfying the version of python and operating system used doesn't help building wheel for installing wordcloud.

Current latest version of wordcloud is 1.8.1 Installing wordcloud:

pip install wordcloud==1.8.1

The code is tested against Python 2.7, 3.4, 3.5, 3.6 and 3.7.

dataninsight
  • 1,069
  • 6
  • 13