pip install wordcloud报错

今天在安装wordcloud模块的时候报错了

(base) C:\Users\zxcl06>pip install wordcloud
Looking in indexes: http://pypi.douban.com/simple/
Collecting wordcloud
  Downloading http://pypi.doubanio.com/packages/be/33/5bdd39587f0e8ede3fe12d9d16d6f1fb5e7a43f29621604a949ee362d013/wordcloud-1.8.1.tar.gz (220 kB)
     |████████████████████████████████| 220 kB 6.4 MB/s
Requirement already satisfied: numpy>=1.6.1 in d:\anaconda\lib\site-packages (from wordcloud) (1.20.3)
Requirement already satisfied: pillow in d:\anaconda\lib\site-packages (from wordcloud) (8.4.0)
Requirement already satisfied: matplotlib in d:\anaconda\lib\site-packages (from wordcloud) (3.4.3)
Requirement already satisfied: python-dateutil>=2.7 in d:\anaconda\lib\site-packages (from matplotlib->wordcloud) (2.8.2)
Requirement already satisfied: pyparsing>=2.2.1 in d:\anaconda\lib\site-packages (from matplotlib->wordcloud) (3.0.4)
Requirement already satisfied: kiwisolver>=1.0.1 in d:\anaconda\lib\site-packages (from matplotlib->wordcloud) (1.3.1)
Requirement already satisfied: cycler>=0.10 in d:\anaconda\lib\site-packages (from matplotlib->wordcloud) (0.10.0)
Requirement already satisfied: six in d:\anaconda\lib\site-packages (from cycler>=0.10->matplotlib->wordcloud) (1.16.0)
Building wheels for collected packages: wordcloud
  Building wheel for wordcloud (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'D:\anaconda\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\zxcl06\\AppData\\Local\\Temp\\pip-install-rijfm2dp\\wordcloud_7346d2fddae5448293f5e4f146a2536a\\setup.py'"'"'; __file__='"'"'C:\\Users\\zxcl06\\AppData\\Local\\Temp\\pip-install-rijfm2dp\\wordcloud_7346d2fddae5448293f5e4f146a2536a\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\zxcl06\AppData\Local\Temp\pip-wheel-79yn34nz'
       cwd: C:\Users\zxcl06\AppData\Local\Temp\pip-install-rijfm2dp\wordcloud_7346d2fddae5448293f5e4f146a2536a\
  Complete output (20 lines):
  running bdist_wheel
  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 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
  ----------------------------------------
  ERROR: Failed building wheel for wordcloud
  Running setup.py clean for wordcloud
Failed to build wordcloud
Installing collected packages: wordcloud
    Running setup.py install for wordcloud ... error
    ERROR: Command errored out with exit status 1:
     command: 'D:\anaconda\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\zxcl06\\AppData\\Local\\Temp\\pip-install-rijfm2dp\\wordcloud_7346d2fddae5448293f5e4f146a2536a\\setup.py'"'"'; __file__='"'"'C:\\Users\\zxcl06\\AppData\\Local\\Temp\\pip-install-rijfm2dp\\wordcloud_7346d2fddae5448293f5e4f146a2536a\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\zxcl06\AppData\Local\Temp\pip-record-90cczmqz\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\anaconda\Include\wordcloud'
         cwd: C:\Users\zxcl06\AppData\Local\Temp\pip-install-rijfm2dp\wordcloud_7346d2fddae5448293f5e4f146a2536a\
    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 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'D:\anaconda\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\zxcl06\\AppData\\Local\\Temp\\pip-install-rijfm2dp\\wordcloud_7346d2fddae5448293f5e4f146a2536a\\setup.py'"'"'; __file__='"'"'C:\\Users\\zxcl06\\AppData\\Local\\Temp\\pip-install-rijfm2dp\\wordcloud_7346d2fddae5448293f5e4f146a2536a\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\zxcl06\AppData\Local\Temp\pip-record-90cczmqz\install-record.txt' --single-version-externally-managed --compile --install-headers 'D:\anaconda\Include\wordcloud' Check the logs for full command output.

其中,发现缺少Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools":,然后我按照报错和网上的办法提示去下载visual studio installer 然后安装C++库,但是不行,而且要下在好几个G的东西。

然后我继续搜索答案。

最终解决办法

  1. 下载*.whl文件

    去这个网站https://www.lfd.uci.edu/~gohlke/pythonlibs,ctrl+f ,搜索Wordcloud(如果你安装其他包报这个错,你就可以搜其他名字,比如 pytho-ldap),然后看你的python版本,比如你的python版本是3.9,那么就选择cp39,如果操作系统是64位的就选amd64的进行下载。搜索结果如图

    image-20220315110702348

  2. 安装whl

    下载好后,打开控制台,cd到whl所在的文件夹,执行pip install 文件名比如我的是下图这样

    image-20220315111104727

安装好whl,就可以用了,如果你电脑上有多个python版本,记得下载的whl文件要和你执行安装的python版本对应,不然会报下面这个错误。比如我anaconda的python是3.9 我用其他版本的python安装,就会有问题

C:\Users\zxcl06\Downloads>pip install wordcloud-1.8.1-cp39-cp39-win_amd64.whl
Looking in indexes: http://pypi.douban.com/simple/
ERROR: wordcloud-1.8.1-cp39-cp39-win_amd64.whl is not a supported wheel on this platform.

pip install wordcloud报错
https://www.zhaojun.inkhttps://www.zhaojun.ink/archives/1027
作者
卑微幻想家
发布于
2022-03-15
许可协议