在命令行用pip install wordcloud
安装wordcloud词云库时,一开始下载都是正常的,我一直用的,所以很快就下好了,眼见马上可以使用了,但是在安装时出现了如下报错:
Running setup.py install for wordcloud ... error
ERROR: Command errored out with exit status 1:
command: 'c:\users\humin\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\humin\\AppData\\Local\\Temp\\pip-install-9_p_gai6\\wordcloud\\setup.py'"'"'; __file__='"'"'C:\\Users\\humin\\AppData\\Local\\Temp\\pip-install-9_p_gai6\\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\humin\AppData\Local\Temp\pip-record-bj25_39a\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\humin\appdata\local\programs\python\python38-32\Include\wordcloud'
cwd: C:\Users\humin\AppData\Local\Temp\pip-install-9_p_gai6\wordcloud\
Complete output (20 lines):
running install
running build
running build_py
creating build
creating build\lib.win32-3.8
creating build\lib.win32-3.8\wordcloud
copying wordcloud\color_from_image.py -> build\lib.win32-3.8\wordcloud
copying wordcloud\tokenization.py -> build\lib.win32-3.8\wordcloud
copying wordcloud\wordcloud.py -> build\lib.win32-3.8\wordcloud
copying wordcloud\wordcloud_cli.py -> build\lib.win32-3.8\wordcloud
copying wordcloud\_version.py -> build\lib.win32-3.8\wordcloud
copying wordcloud\__init__.py -> build\lib.win32-3.8\wordcloud
copying wordcloud\__main__.py -> build\lib.win32-3.8\wordcloud
copying wordcloud\stopwords -> build\lib.win32-3.8\wordcloud
copying wordcloud\DroidSansMono.ttf -> build\lib.win32-3.8\wordcloud
UPDATING build\lib.win32-3.8\wordcloud/_version.py
set build\lib.win32-3.8\wordcloud/_version.py to '1.7.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\humin\appdata\local\programs\python\python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\humin\\AppData\\Local\\Temp\\pip-install-9_p_gai6\\wordcloud\\setup.py'"'"'; __file__='"'"'C:\\Users\\humin\\AppData\\Local\\Temp\\pip-install-9_p_gai6\\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\humin\AppData\Local\Temp\pip-record-bj25_39a\install-record.txt' --single-version-externally-managed --compile --install-headers 'c:\users\humin\appdata\local\programs\python\python38-32\Include\wordcloud' Check the logs for full command output.
仔细看错误提示,有几点需要注意的地方:
ERROR: Command errored out with exit status 1
UPDATING build\lib.win32-3.8\wordcloud/_version.py
set build\lib.win32-3.8\wordcloud/_version.py to ‘1.7.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/
所以我就从这3点入手解决。
可能是wordcloud的版本与我安装的python版本不匹配导致的,我是python3.8版本的。所以准备直接去下载对应版本的包来安装,不用自动下载自动安装的模式了。
直接在命令行输入python
即可:
C:\Users\humin>python
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:20:19) [MSC v.1925 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
这里可以看到我的python是32位的python3.8.3版本。
下载地址:点击这里
会看到眼花缭乱的第三方库:
教大家一个方法,快速的找到你想要的库
按F12打开网页编辑页面
再同时按Ctrl + F,打开搜索栏,输入wordcloud,就可以在原始页面高亮显示你所要找的内容了
(刚发现多此一举了,直接在原始页面按住Ctrl + F就可以了。)
然后打开wordcloud链接会看到:
我对应的版本是cp38-win32,下载即可。
C:\Users\humin\AppData\Local\Programs\Python\Python38-32
C:\Users\humin\AppData\Local\Programs\Python\Python38-32>cd whl
C:\Users\humin\AppData\Local\Programs\Python\Python38-32\whl>
输入下面的命令就可以安装了:
pip install wordcloud-1.7.0-cp38-cp38-win32.whl
当然安装包的名称要写你所下载的,不要照搬我的代码。
以后不管是什么第三方库出现问题,都可以尝试下这种方法。自己去挑选与所安装python版本兼容的库,问题会少很多。
更多问题请访问:我的个人博客
大家一起学习交流!